diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-02-15 16:11:24 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-02-15 16:11:24 +0200 |
commit | d065bae323838734556de2693b6b004c98c95092 (patch) | |
tree | c51888cc0c2628f1a3e5cd2ba05b4297c2a22869 /src/porting.cpp | |
parent | be7391c2b1153c817a69aabd2a34e082c79df58f (diff) | |
download | minetest-d065bae323838734556de2693b6b004c98c95092.tar.gz minetest-d065bae323838734556de2693b6b004c98c95092.tar.bz2 minetest-d065bae323838734556de2693b6b004c98c95092.zip |
Ctrl+C handling on POSIX, some commands for server and other tweaking
Diffstat (limited to 'src/porting.cpp')
-rw-r--r-- | src/porting.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 592636336..f92b291ac 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -29,6 +29,53 @@ with this program; if not, write to the Free Software Foundation, Inc., namespace porting { +/* + Signal handler (grabs Ctrl-C on POSIX systems) +*/ + +#if !defined(_WIN32) // POSIX + #include <signal.h> + +bool g_killed = false; + +void sigint_handler(int sig) +{ + if(g_killed == false) + { + dstream<<DTIME<<"sigint_handler(): " + <<"Ctrl-C pressed, shutting down."<<std::endl; + g_killed = true; + } + else + { + (void)signal(SIGINT, SIG_DFL); + } +} + +void signal_handler_init(void) +{ + dstream<<"signal_handler_init()"<<std::endl; + (void)signal(SIGINT, sigint_handler); +} + +#else // _WIN32 + +void signal_handler_init(void) +{ + // No-op +} + +#endif + +bool * signal_handler_killstatus(void) +{ + return &g_killed; +} + +/* + Path mangler +*/ + std::string path_data = "../data"; std::string path_userdata = "../"; |