summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-06 10:17:58 -0400
committerDwight <dmerriman@gmail.com>2008-06-06 10:17:58 -0400
commit1625885eb7d094d819eb30e706c5f881cb8bc901 (patch)
tree8bb28af936fa9561365de3b9572f92f8aa7aa8f1
parent3051b961cac30f9bf81ac72b816ddb5e8e3c2ee9 (diff)
downloadmongo-1625885eb7d094d819eb30e706c5f881cb8bc901.tar.gz
on kill, finish curr cmd.
-rw-r--r--db/db.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/db/db.cpp b/db/db.cpp
index c50c5769420..cd8f9005ede 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -274,7 +274,7 @@ public:
};
void listen(int port) {
- const char *Version = "db version: 110 2jun2008 embedded obj queries";
+ const char *Version = "db version: 111 6jun2008";
problem() << Version << endl;
cout << Version << endl;
pdfileInit();
@@ -579,25 +579,27 @@ void pipeSigHandler( int signal ) {
psignal( signal, "Signal Received : ");
}
-void segvhandler(int x) {
+void segvhandler(int x) {
cout << "got SIGSEGV " << x << ", terminating :-(" << endl;
problem() << "got SIGSEGV " << x << ", terminating :-(" << endl;
- exit(-9);
+ exit(9);
}
void mysighandler(int x) {
- // [dm] not working. why?
- // [gmj] because the VM catches sig 3 to do a thread dump
- cout << "got kill or ctrl c signal " << x << ", terminating" << endl;
- problem() << "got kill or ctrl c signal " << x << ", terminating" << endl;
- exit(0);
+ signal(x, SIG_IGN);
+ cout << "got kill or ctrl c signal " << x << ", will terminate after current cmd ends" << endl;
+ problem() << "got kill or ctrl c signal " << x << ", will terminate after current cmd ends" << endl;
+ {
+ lock lk(dbMutex);
+ cout << "exiting" << endl;
+ problem() << "exiting" << endl;
+ exit(12);
+ }
}
void setupSignals() {
- cout << "SETUPSIGNALS " << signal(SIGINT, mysighandler) << endl;
-// assert( signal(SIGINT, mysighandler) != SIG_ERR );
+ assert( signal(SIGINT, mysighandler) != SIG_ERR );
assert( signal(SIGTERM, mysighandler) != SIG_ERR );
- assert( signal(SIGQUIT, mysighandler) != SIG_ERR );
assert( signal(SIGSEGV, segvhandler) != SIG_ERR );
}
@@ -607,7 +609,7 @@ void setupSignals() {}
void initAndListen(int listenPort, const char *dbPath, const char *appserverLoc = null) {
- setupSignals();
+// setupSignals();
/*
* ensure that the dbpath ends w/ '/' as that's key in preventing things like
@@ -637,6 +639,8 @@ void initAndListen(int listenPort, const char *dbPath, const char *appserverLoc
JavaJS = new JavaJSImpl(appserverLoc);
javajstest();
+ setupSignals();
+
listen(listenPort);
}