SERVER-705 return return code when stopping mongod program
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user