diff options
author | est31 <MTest31@outlook.com> | 2016-06-24 20:43:29 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2016-06-24 20:43:29 +0200 |
commit | ab7a5c4ff138c39a2491592731d677c9f392caa0 (patch) | |
tree | 3cb2fafa362a75f7b4b14764e1a133e3bdbdea64 | |
parent | 9997e2030c86b938d1889ee71522bc26d01226e6 (diff) | |
download | minetest-ab7a5c4ff138c39a2491592731d677c9f392caa0.tar.gz minetest-ab7a5c4ff138c39a2491592731d677c9f392caa0.tar.bz2 minetest-ab7a5c4ff138c39a2491592731d677c9f392caa0.zip |
Also shut down when SIGTERM was received
Fixes #4251
-rw-r--r-- | src/porting.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 98b85b7d0..7ded58b3f 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -75,11 +75,16 @@ bool * signal_handler_killstatus(void) #if !defined(_WIN32) // POSIX #include <signal.h> -void sigint_handler(int sig) +void signal_handler(int sig) { if (!g_killed) { - dstream << "INFO: sigint_handler(): " - << "Ctrl-C pressed, shutting down." << std::endl; + if (sig == SIGINT) { + dstream << "INFO: signal_handler(): " + << "Ctrl-C pressed, shutting down." << std::endl; + } else if (sig == SIGTERM) { + dstream << "INFO: signal_handler(): " + << "got SIGTERM, shutting down." << std::endl; + } // Comment out for less clutter when testing scripts /*dstream << "INFO: sigint_handler(): " @@ -88,13 +93,14 @@ void sigint_handler(int sig) g_killed = true; } else { - (void)signal(SIGINT, SIG_DFL); + (void)signal(sig, SIG_DFL); } } void signal_handler_init(void) { - (void)signal(SIGINT, sigint_handler); + (void)signal(SIGINT, signal_handler); + (void)signal(SIGTERM, signal_handler); } #else // _WIN32 |