diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/i_main.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/i_main.c b/src/i_main.c index c8f77b3f..6c60ad69 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_main.c 57 2005-08-30 22:11:10Z fraggle $ +// $Id: i_main.c 86 2005-09-07 21:40:28Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.4 2005/09/07 21:40:28 fraggle +// Catch signals and exit cleanly +// // Revision 1.3 2005/08/30 22:11:10 fraggle // Windows fixes // @@ -38,19 +41,22 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_main.c 57 2005-08-30 22:11:10Z fraggle $"; +rcsid[] = "$Id: i_main.c 86 2005-09-07 21:40:28Z fraggle $"; +#include <signal.h> #include "doomdef.h" - +#include "i_system.h" #include "m_argv.h" #include "d_main.h" -int -main -( int argc, - char** argv ) +void SignalHandler(int signum) +{ + I_Error("Aborting due to signal %i\n", signum); +} + +int main(int argc, char **argv) { // save arguments @@ -58,6 +64,17 @@ main myargc = argc; myargv = argv; + signal(SIGSEGV, SignalHandler); + signal(SIGTERM, SignalHandler); + signal(SIGILL, SignalHandler); + signal(SIGINT, SignalHandler); + signal(SIGFPE, SignalHandler); + signal(SIGABRT, SignalHandler); + signal(SIGHUP, SignalHandler); +#ifdef SIGPIPE + signal(SIGHUP, SignalHandler); +#endif + #ifdef _WIN32 // restore stdout/stderr @@ -65,6 +82,7 @@ main freopen("CON", "w", stderr); #endif + // start doom D_DoomMain (); |