summaryrefslogtreecommitdiff
path: root/src/common/core.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-01-25 09:43:09 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-01-25 10:14:44 -0800
commit34f0540da418b01dd4d49f6ecf72569d3cfecfdf (patch)
treebf7c4623b0d794e4db8c72b0906bb40807d62ba8 /src/common/core.cpp
parent9a4c3a44476f3306a8deed8a836e8fbc25ceb55f (diff)
downloadtmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.gz
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.bz2
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.tar.xz
tmwa-34f0540da418b01dd4d49f6ecf72569d3cfecfdf.zip
Implement unified config parsing (mostly)
Diffstat (limited to 'src/common/core.cpp')
-rw-r--r--src/common/core.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/common/core.cpp b/src/common/core.cpp
index 727babd..fe2f660 100644
--- a/src/common/core.cpp
+++ b/src/common/core.cpp
@@ -10,6 +10,8 @@
#include "../strings/zstring.hpp"
+#include "../io/cxxstdio.hpp"
+
#include "random.hpp"
#include "socket.hpp"
#include "timer.hpp"
@@ -46,12 +48,15 @@ sigfunc compat_signal(int signo, sigfunc func)
return oact.sa_handler;
}
+volatile
+bool runflag = true;
+
static
void chld_proc(int)
{
wait(NULL);
}
-static __attribute__((noreturn))
+static
void sig_proc(int)
{
for (int i = 1; i < 31; ++i)
@@ -59,12 +64,9 @@ void sig_proc(int)
#pragma GCC diagnostic ignored "-Wold-style-cast"
compat_signal(i, SIG_IGN);
#pragma GCC diagnostic pop
- term_func();
- _exit(0);
+ runflag = false;
}
-bool runflag = true;
-
/*
Note about fatal signals:
@@ -83,6 +85,12 @@ int main(int argc, char **argv)
for (int i = 0; i < argc; ++i)
args[i] = ZString(strings::really_construct_from_a_pointer, argv[i], nullptr);
do_init(argc, args);
+
+ if (!runflag)
+ {
+ PRINTF("Fatal error during startup; exiting\n");
+ return 1;
+ }
// set up exit handlers *after* the initialization has happened.
// This is because term_func is likely to depend on successful init.