diff --git a/jstests/shellkillop.js b/jstests/shellkillop.js index e8a97633eaf..10914580079 100644 --- a/jstests/shellkillop.js +++ b/jstests/shellkillop.js @@ -7,7 +7,7 @@ for( i = 0; i < 100000; ++i ) { } assert.eq( 100000, db[ baseName ].count() ); -spawn = startMongoProgramNoConnect( "mongo", "--port", myPort(), "--eval", "db." + baseName + ".update( {}, {$set:{i:\"abcdefghijkl\"}}, false, true ); db." + baseName + ".count();" ); +spawn = startMongoProgramNoConnect( "mongo", "--autokillop", "--port", myPort(), "--eval", "db." + baseName + ".update( {}, {$set:{i:\"abcdefghijkl\"}}, false, true ); db." + baseName + ".count();" ); sleep( 100 ); stopMongoProgramByPid( spawn ); sleep( 100 ); diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp index 2b859542d94..d35e44eb6e3 100644 --- a/shell/dbshell.cpp +++ b/shell/dbshell.cpp @@ -52,6 +52,8 @@ string historyFile; bool gotInterrupted = 0; bool inMultiLine = 0; static volatile bool atPrompt = false; // can eval before getting to prompt +bool autoKillOp = false; + #if defined(USE_READLINE) && !defined(__freebsd__) && !defined(__openbsd__) && !defined(_WIN32) #define CTRLC_HANDLE @@ -168,14 +170,17 @@ void killOps() { if ( atPrompt ) return; - cout << endl << "do you want to kill the current op on the server? (y/n): "; - cout.flush(); + if ( !autoKillOp ) { + cout << endl << "do you want to kill the current op on the server? (y/n): "; + cout.flush(); - char yn; - cin >> yn; + char yn; + cin >> yn; + + if (yn != 'y' && yn != 'Y') + return; + } - if (yn != 'y' && yn != 'Y') - return; vector< string > uris; for( map< const void*, string >::iterator i = mongo::shellUtils::_allMyUris.begin(); i != mongo::shellUtils::_allMyUris.end(); ++i ) @@ -447,6 +452,7 @@ int _main(int argc, char* argv[]) { ("dbaddress", po::value(), "dbaddress") ("files", po::value< vector >(), "files") ("nokillop", "nokillop") // for testing, kill op will also be disabled automatically if the tests starts a mongo program + ("autokillop", "autokillop") // for testing, will kill op without prompting ; positional_options.add("dbaddress", 1); @@ -507,6 +513,9 @@ int _main(int argc, char* argv[]) { if (params.count("nokillop")) { mongo::shellUtils::_nokillop = true; } + if (params.count("autokillop")) { + autoKillOp = true; + } /* This is a bit confusing, here are the rules: *