Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1213)

Unified Diff: runtime/bin/process_linux.cc

Issue 1076093004: Make all of stdout/stderr/stdin pipes close-on-exec when spawing child processes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_linux.cc
diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc
index a511cd94f53082b3de6513789b59fceed49e8caf..cd9c639b9fa6abdb9bee4784a50faa7c8e3996cd 100644
--- a/runtime/bin/process_linux.cc
+++ b/runtime/bin/process_linux.cc
@@ -378,34 +378,29 @@ class ProcessStarter {
private:
int CreatePipes() {
int result;
- result = TEMP_FAILURE_RETRY(pipe(exec_control_));
+ result = TEMP_FAILURE_RETRY(pipe2(exec_control_, O_CLOEXEC));
if (result < 0) {
return CleanupAndReturnError();
}
- FDUtils::SetCloseOnExec(exec_control_[0]);
- FDUtils::SetCloseOnExec(exec_control_[1]);
// For a detached process the pipe to connect stdout is still used for
// signaling when to do the first fork.
- result = TEMP_FAILURE_RETRY(pipe(read_in_));
+ result = TEMP_FAILURE_RETRY(pipe2(read_in_, O_CLOEXEC));
if (result < 0) {
return CleanupAndReturnError();
}
- FDUtils::SetCloseOnExec(read_in_[0]);
// For detached processes the pipe to connect stderr and stdin are not used.
if (mode_ != kDetached) {
- result = TEMP_FAILURE_RETRY(pipe(read_err_));
+ result = TEMP_FAILURE_RETRY(pipe2(read_err_, O_CLOEXEC));
if (result < 0) {
return CleanupAndReturnError();
}
- FDUtils::SetCloseOnExec(read_err_[0]);
- result = TEMP_FAILURE_RETRY(pipe(write_out_));
+ result = TEMP_FAILURE_RETRY(pipe2(write_out_, O_CLOEXEC));
if (result < 0) {
return CleanupAndReturnError();
}
- FDUtils::SetCloseOnExec(write_out_[1]);
}
return 0;
@@ -429,25 +424,17 @@ class ProcessStarter {
void ExecProcess() {
- VOID_TEMP_FAILURE_RETRY(close(write_out_[1]));
- VOID_TEMP_FAILURE_RETRY(close(read_in_[0]));
- VOID_TEMP_FAILURE_RETRY(close(read_err_[0]));
- VOID_TEMP_FAILURE_RETRY(close(exec_control_[0]));
-
if (TEMP_FAILURE_RETRY(dup2(write_out_[0], STDIN_FILENO)) == -1) {
ReportChildError();
}
- VOID_TEMP_FAILURE_RETRY(close(write_out_[0]));
if (TEMP_FAILURE_RETRY(dup2(read_in_[1], STDOUT_FILENO)) == -1) {
ReportChildError();
}
- VOID_TEMP_FAILURE_RETRY(close(read_in_[1]));
if (TEMP_FAILURE_RETRY(dup2(read_err_[1], STDERR_FILENO)) == -1) {
ReportChildError();
}
- VOID_TEMP_FAILURE_RETRY(close(read_err_[1]));
if (working_directory_ != NULL &&
TEMP_FAILURE_RETRY(chdir(working_directory_)) == -1) {
@@ -526,12 +513,10 @@ class ProcessStarter {
int RegisterProcess(pid_t pid) {
int result;
int event_fds[2];
- result = TEMP_FAILURE_RETRY(pipe(event_fds));
+ result = TEMP_FAILURE_RETRY(pipe2(event_fds, O_CLOEXEC));
if (result < 0) {
return CleanupAndReturnError();
}
- FDUtils::SetCloseOnExec(event_fds[0]);
- FDUtils::SetCloseOnExec(event_fds[1]);
ProcessInfoList::AddProcess(pid, event_fds[1]);
*exit_event_ = event_fds[0];
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698