diff options
author | Brad King <brad.king@kitware.com> | 2020-06-12 14:09:04 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-06-12 14:09:11 (GMT) |
commit | 02a82e4cd409f0bbdf65397eacf29a2702b99e63 (patch) | |
tree | 06a617e5eb86de9661605887a36f78633fa1842f /Source | |
parent | 448a8deb744217d6314df639aec7d89da89a061a (diff) | |
parent | 19689d34e6781247cd229b3e0034baabe79b4d0c (diff) | |
download | CMake-02a82e4cd409f0bbdf65397eacf29a2702b99e63.zip CMake-02a82e4cd409f0bbdf65397eacf29a2702b99e63.tar.gz CMake-02a82e4cd409f0bbdf65397eacf29a2702b99e63.tar.bz2 |
Merge topic 'ccmake-ncurses-init'
19689d34e6 ccmake: Display an error and interrupt execution if ncurses failed
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4835
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CursesDialog/ccmake.cxx | 16 |
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 */ |