summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2020-06-01 13:39:53 (GMT)
committerBrad King <brad.king@kitware.com>2020-06-11 11:24:05 (GMT)
commit19689d34e6781247cd229b3e0034baabe79b4d0c (patch)
tree121b710f9637ea5b36187dbd7d8cda3589b2a53e /Source/CursesDialog
parent21218f5c1277ff840e1a7b6128af3b2abe0d35d3 (diff)
downloadCMake-19689d34e6781247cd229b3e0034baabe79b4d0c.zip
CMake-19689d34e6781247cd229b3e0034baabe79b4d0c.tar.gz
CMake-19689d34e6781247cd229b3e0034baabe79b4d0c.tar.bz2
ccmake: Display an error and interrupt execution if ncurses failed
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r--Source/CursesDialog/ccmake.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 9a26db5..85e256b 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -2,11 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include <csignal>
+#include <cstdio>
+#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
+#include <unistd.h>
+
#include "cmsys/Encoding.hxx"
#include "cmCursesColor.h"
@@ -54,7 +58,12 @@ void onsig(int /*unused*/)
{
if (cmCursesForm::CurrentForm) {
endwin();
- initscr(); /* Initialization */
+ if (initscr() == nullptr) {
+ static const char errmsg[] = "Error: ncurses initialization failed\n";
+ auto r = write(STDERR_FILENO, errmsg, sizeof(errmsg) - 1);
+ static_cast<void>(r);
+ exit(1);
+ }
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
@@ -124,7 +133,10 @@ int main(int argc, char const* const* argv)
cmCursesForm::DebugStart();
}
- initscr(); /* Initialization */
+ if (initscr() == nullptr) {
+ fprintf(stderr, "Error: ncurses initialization failed\n");
+ exit(1);
+ }
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */