diff options
author | Aaron <aaron@10gen.com> | 2010-03-08 12:54:39 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-03-09 09:57:20 -0800 |
commit | 063f651c6bcaa321ad2cb9bc534b724ce60aef6a (patch) | |
tree | bd877678f9de37a7989924ba820298ca5395a78b | |
parent | 97515db5b80e2ca8bbdcda0158695a91dc104b22 (diff) | |
download | mongo-063f651c6bcaa321ad2cb9bc534b724ce60aef6a.tar.gz |
SERVER-705 return return code when stopping mongod program
-rw-r--r-- | shell/servers.js | 2 | ||||
-rw-r--r-- | shell/utils.cpp | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/shell/servers.js b/shell/servers.js index 8d15e056777..9a836747f70 100644 --- a/shell/servers.js +++ b/shell/servers.js @@ -599,7 +599,7 @@ ReplTest.prototype.stop = function( master , signal ){ this.stop( false ); return; } - stopMongod( this.getPort( master ) , signal || 15 ); + return stopMongod( this.getPort( master ) , signal || 15 ); } allocatePorts = function( n ) { diff --git a/shell/utils.cpp b/shell/utils.cpp index 0db5734cdf3..60b9ea34c20 100644 --- a/shell/utils.cpp +++ b/shell/utils.cpp @@ -321,12 +321,13 @@ namespace mongo { return undefined_; } - void killDb( int port, pid_t _pid, int signal ) { + int killDb( int port, pid_t _pid, int signal ) { pid_t pid; + int exitCode = 0; if ( port > 0 ) { if( dbs.count( port ) != 1 ) { cout << "No db started on port: " << port << endl; - return; + return 0; } pid = dbs[ port ].first; } else { @@ -346,6 +347,7 @@ namespace mongo { } int temp; int ret = waitpid( pid, &temp, WNOHANG ); + exitCode = WEXITSTATUS( temp ); if ( ret == pid ) break; sleepms( 1000 ); @@ -368,6 +370,8 @@ namespace mongo { if ( i > 4 || signal == SIGKILL ) { sleepms( 4000 ); // allow operating system to reclaim resources } + + return exitCode; } int getSignal( const BSONObj &a ) { @@ -386,18 +390,18 @@ namespace mongo { assert( a.nFields() == 1 || a.nFields() == 2 ); assert( a.firstElement().isNumber() ); int port = int( a.firstElement().number() ); - killDb( port, 0, getSignal( a ) ); + int code = killDb( port, 0, getSignal( a ) ); cout << "shell: stopped mongo program on port " << port << endl; - return undefined_; + return BSON( "" << code ); } BSONObj StopMongoProgramByPid( const BSONObj &a ) { assert( a.nFields() == 1 || a.nFields() == 2 ); assert( a.firstElement().isNumber() ); int pid = int( a.firstElement().number() ); - killDb( 0, pid, getSignal( a ) ); + int code = killDb( 0, pid, getSignal( a ) ); cout << "shell: stopped mongo program on pid " << pid << endl; - return undefined_; + return BSON( "" << code ); } void KillMongoProgramInstances() { |