summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2005-09-07 21:40:28 +0000
committerSimon Howard2005-09-07 21:40:28 +0000
commitfaa2a505ba7ee8c17679b208e4bfb6b30623a332 (patch)
tree1ba76d0e333fd7678512b2b5f9c88d2ceb1bea1e
parent3bbed813e4ee72bd7fcf974e17835ab07c2b74b4 (diff)
downloadchocolate-doom-faa2a505ba7ee8c17679b208e4bfb6b30623a332.tar.gz
chocolate-doom-faa2a505ba7ee8c17679b208e4bfb6b30623a332.tar.bz2
chocolate-doom-faa2a505ba7ee8c17679b208e4bfb6b30623a332.zip
Catch signals and exit cleanly
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 86
-rw-r--r--src/i_main.c32
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 ();