summaryrefslogtreecommitdiff
path: root/src/mongo/shell/shell_utils_launcher.cpp
diff options
context:
space:
mode:
authorRyan Timmons <ryan.timmons@mongodb.com>2019-09-10 18:03:51 +0000
committerevergreen <evergreen@mongodb.com>2019-09-10 18:03:51 +0000
commite7cc9e482621415c4c5361a98edb469a2024dcb7 (patch)
tree209ddc5a5508d8e203a4241535ba0c5c03088941 /src/mongo/shell/shell_utils_launcher.cpp
parent3e302760894b08b7a8d57f87106b152e165bc4dd (diff)
downloadmongo-e7cc9e482621415c4c5361a98edb469a2024dcb7.tar.gz
SERVER-43153 Expose pids of spawned processes in the shell
Diffstat (limited to 'src/mongo/shell/shell_utils_launcher.cpp')
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index 752c7724e42..dba5ded531e 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -1101,12 +1101,24 @@ std::vector<ProcessId> getRunningMongoChildProcessIds() {
return outPids;
}
+BSONObj RunningMongoChildProcessIds(const BSONObj&, void*) {
+ std::vector<ProcessId> pids = getRunningMongoChildProcessIds();
+ BSONObjBuilder bob;
+ BSONArrayBuilder pidArr(bob.subarrayStart("runningPids"));
+ for (const auto& pid : pids) {
+ pidArr << pid.asInt64();
+ }
+ pidArr.done();
+ return bob.obj();
+}
+
MongoProgramScope::~MongoProgramScope() {
DESTRUCTOR_GUARD(KillMongoProgramInstances(); ClearRawMongoProgramOutput(BSONObj(), nullptr);)
}
void installShellUtilsLauncher(Scope& scope) {
scope.injectNative("_startMongoProgram", StartMongoProgram);
+ scope.injectNative("_runningMongoChildProcessIds", RunningMongoChildProcessIds);
scope.injectNative("runProgram", RunMongoProgram);
scope.injectNative("run", RunMongoProgram);
scope.injectNative("_runMongoProgram", RunMongoProgram);