diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-08-24 11:54:06 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-08-24 11:54:06 -0400 |
commit | a2e000830f884d3be8938b87ffaf6b84a62e5a50 (patch) | |
tree | 01a01973f7966f5400a12626d337f9ba3c4abed8 /shell | |
parent | 1681f080f05df5a04fc7228e66cf40494e345125 (diff) | |
download | mongo-a2e000830f884d3be8938b87ffaf6b84a62e5a50.tar.gz |
runMongoProgram
Diffstat (limited to 'shell')
-rw-r--r-- | shell/utils.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/shell/utils.cpp b/shell/utils.cpp index f14a4c54438..680f5a1c91f 100644 --- a/shell/utils.cpp +++ b/shell/utils.cpp @@ -82,11 +82,13 @@ namespace mongo { BSONObjBuilder b; b << "name" << p.string(); b.appendBool( "isDirectory", is_directory( p ) ); + if ( ! is_directory( p ) ) + b.append( "size" , (double)file_size( p ) ); + stringstream ss; ss << num; string name = ss.str(); lst.append( name.c_str(), b.done() ); - num++; i++; } @@ -260,10 +262,11 @@ namespace mongo { assert( pid_ != -1 ); if ( pid_ == 0 ) { + assert( dup2( pipeEnds[ 1 ], STDOUT_FILENO ) != -1 ); assert( dup2( pipeEnds[ 1 ], STDERR_FILENO ) != -1 ); execvp( argv_[ 0 ], argv_ ); - assert( "Unable to start program" == 0 ); + massert( "Unable to start program" , 0 ); } cout << "shell: started mongo program"; @@ -327,6 +330,16 @@ namespace mongo { return BSON( string( "" ) << int( r.pid() ) ); } + BSONObj RunMongoProgram( const BSONObj &a ) { + MongoProgramRunner r( a ); + r.start(); + boost::thread t( r ); + int temp; + waitpid( r.pid() , &temp , 0 ); + shells.erase( r.pid() ); + return BSON( string( "" ) << int( r.pid() ) ); + } + BSONObj ResetDbpath( const BSONObj &a ) { assert( a.nFields() == 1 ); string path = a.firstElement().valuestrsafe(); @@ -451,6 +464,7 @@ namespace mongo { #if !defined(_WIN32) scope.injectNative( "allocatePorts", AllocatePorts ); scope.injectNative( "_startMongoProgram", StartMongoProgram ); + scope.injectNative( "runMongoProgram", RunMongoProgram ); scope.injectNative( "stopMongod", StopMongoProgram ); scope.injectNative( "stopMongoProgram", StopMongoProgram ); scope.injectNative( "stopMongoProgramByPid", StopMongoProgramByPid ); |