You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/11/04 02:31:13 UTC
svn commit: r1405486 -
/incubator/mesos/branches/0.10.0/src/slave/process_based_isolation_module.cpp
Author: benh
Date: Sun Nov 4 01:31:12 2012
New Revision: 1405486
URL: http://svn.apache.org/viewvc?rev=1405486&view=rev
Log:
*** MODIFIED FOR 0.10.0 ***
Fixed potential issue with forking in process_based_isolation_module.cpp.
Modified:
incubator/mesos/branches/0.10.0/src/slave/process_based_isolation_module.cpp
Modified: incubator/mesos/branches/0.10.0/src/slave/process_based_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/branches/0.10.0/src/slave/process_based_isolation_module.cpp?rev=1405486&r1=1405485&r2=1405486&view=diff
==============================================================================
--- incubator/mesos/branches/0.10.0/src/slave/process_based_isolation_module.cpp (original)
+++ incubator/mesos/branches/0.10.0/src/slave/process_based_isolation_module.cpp Sun Nov 4 01:31:12 2012
@@ -17,6 +17,8 @@
*/
#include <signal.h>
+#include <stdio.h> // For perror.
+#include <string.h>
#include <map>
@@ -148,29 +150,33 @@ void ProcessBasedIsolationModule::launch
dispatch(slave, &Slave::executorStarted,
frameworkId, executorId, pid);
} else {
- // In child process, make cleanup easier.
+ // In child process, we make cleanup easier by putting process
+ // into it's own session. DO NOT USE GLOG!
+ close(pipes[0]);
+
// NOTE: We setsid() in a loop because setsid() might fail if another
// process has the same process group id as the calling process.
- close(pipes[0]);
while ((pid = setsid()) == -1) {
- PLOG(ERROR) << "Could not put executor in own session, "
- << "forking another process and retrying";
+ perror("Could not put executor in own session");
+
+ std::cerr << "Forking another process and retrying ..." << std::endl;
if ((pid = fork()) == -1) {
- LOG(ERROR) << "Failed to fork to launch executor";
- exit(-1);
+ perror("Failed to fork to launch executor");
+ abort();
}
if (pid) {
// In parent process.
// It is ok to suicide here, though process reaper signals the exit,
// because the process isolation module ignores unknown processes.
- exit(-1);
+ exit(0);
}
}
if (write(pipes[1], &pid, sizeof(pid)) != sizeof(pid)) {
- PLOG(FATAL) << "Failed to write PID on pipe";
+ perror("Failed to write PID on pipe");
+ abort();
}
close(pipes[1]);
@@ -180,7 +186,8 @@ void ProcessBasedIsolationModule::launch
executorInfo, directory);
if (launcher->run() < 0) {
- LOG(FATAL) << "Failed to launch executor";
+ std::cerr << "Failed to launch executor" << std::endl;
+ abort();
}
}
}
@@ -215,7 +222,7 @@ void ProcessBasedIsolationModule::killEx
// TODO(vinod): Also (recursively) kill processes belonging to the
// same session, but have a different process group id.
if (killpg(pid, SIGKILL) == -1 && errno != ESRCH) {
- LOG(ERROR) << "ERROR! Killing process group " << pid;
+ PLOG(WARNING) << "Failed to kill process group " << pid;
}
ProcessInfo* info = infos[frameworkId][executorId];