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/10/31 17:39:17 UTC
svn commit: r1404236 - in /incubator/mesos/trunk/src:
slave/process_based_isolation_module.cpp tests/script.cpp
Author: benh
Date: Wed Oct 31 16:39:16 2012
New Revision: 1404236
URL: http://svn.apache.org/viewvc?rev=1404236&view=rev
Log:
Fixed potential issue with forking in process_based_isolation_module.cpp.
Modified:
incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
incubator/mesos/trunk/src/tests/script.cpp
Modified: incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp?rev=1404236&r1=1404235&r2=1404236&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp Wed Oct 31 16:39:16 2012
@@ -18,6 +18,7 @@
#include <errno.h>
#include <signal.h>
+#include <stdio.h> // For perror.
#include <string.h>
#include <map>
@@ -150,29 +151,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]);
@@ -182,7 +187,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();
}
}
}
@@ -217,7 +223,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];
Modified: incubator/mesos/trunk/src/tests/script.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/script.cpp?rev=1404236&r1=1404235&r2=1404236&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/script.cpp (original)
+++ incubator/mesos/trunk/src/tests/script.cpp Wed Oct 31 16:39:16 2012
@@ -79,7 +79,7 @@ void execute(const string& script)
<< strsignal(WTERMSIG(status)) << "'";
}
} else {
- // In child process, DO NOT USE GLOG!
+ // In child process. DO NOT USE GLOG!
// Start by cd'ing into the temporary directory.
if (!os::chdir(directory.get())) {