summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-01-30 15:15:48 -0500
committerAaron <aaron@10gen.com>2009-01-30 15:15:48 -0500
commit3613577677268a8c69fe1cf50de99e2ac434d025 (patch)
treeef675beecf15036d3c68bd016409ade387a0a5a0 /shell
parent02e22ec1c206b13025cd2ce7a4cb9797ae0178d5 (diff)
downloadmongo-3613577677268a8c69fe1cf50de99e2ac434d025.tar.gz
Better kill
Diffstat (limited to 'shell')
-rw-r--r--shell/ShellUtils.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/shell/ShellUtils.cpp b/shell/ShellUtils.cpp
index 5747e0d63be..0c5a8c7a0ee 100644
--- a/shell/ShellUtils.cpp
+++ b/shell/ShellUtils.cpp
@@ -299,11 +299,27 @@ v8::Handle< v8::Value > ResetDbpath( const v8::Arguments &a ) {
}
void killDb( int port ) {
- assert( dbs.count( port ) == 1 );
+ if( dbs.count( port ) != 1 ) {
+ cout << "No db started on port: " << port << endl;
+ return;
+ }
+
pid_t pid = dbs[ port ];
kill( pid, SIGTERM );
- int temp;
- waitpid( pid, &temp, 0 );
+
+ boost::xtime xt;
+ boost::xtime_get(&xt, boost::TIME_UTC);
+ ++xt.sec;
+ int i = 0;
+ for( ; i < 5; ++i, ++xt.sec ) {
+ int temp;
+ if( waitpid( pid, &temp, WNOHANG ) != 0 )
+ break;
+ boost::thread::sleep( xt );
+ }
+ if ( i == 5 )
+ kill( pid, SIGKILL );
+
dbs.erase( port );
}