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

Side by Side Diff: runtime/bin/process_android.cc

Issue 11644017: Set close-on-exec flag on pipe() and epoll() file descriptors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/process.h" 5 #include "bin/process.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <poll.h> 9 #include <poll.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (initialized_) { 117 if (initialized_) {
118 return true; 118 return true;
119 } 119 }
120 120
121 // Allocate a pipe that the signal handler can write a byte to and 121 // Allocate a pipe that the signal handler can write a byte to and
122 // that the exit handler thread can poll. 122 // that the exit handler thread can poll.
123 int result = TEMP_FAILURE_RETRY(pipe(sig_chld_fds_)); 123 int result = TEMP_FAILURE_RETRY(pipe(sig_chld_fds_));
124 if (result < 0) { 124 if (result < 0) {
125 return false; 125 return false;
126 } 126 }
127 FDUtils::SetCloseOnExec(sig_chld_fds_[0]);
128 FDUtils::SetCloseOnExec(sig_chld_fds_[1]);
127 129
128 // Start thread that polls the pipe and handles process exits when 130 // Start thread that polls the pipe and handles process exits when
129 // data is received on the pipe. 131 // data is received on the pipe.
130 result = dart::Thread::Start(ExitCodeHandlerEntry, sig_chld_fds_[0]); 132 result = dart::Thread::Start(ExitCodeHandlerEntry, sig_chld_fds_[0]);
131 if (result != 0) { 133 if (result != 0) {
132 FATAL1("Failed to start exit code handler worker thread %d", result); 134 FATAL1("Failed to start exit code handler worker thread %d", result);
133 } 135 }
134 136
135 // Mark write end non-blocking. 137 // Mark write end non-blocking.
136 FDUtils::SetNonBlocking(sig_chld_fds_[1]); 138 FDUtils::SetNonBlocking(sig_chld_fds_[1]);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 SetChildOsErrorMessage(os_error_message); 477 SetChildOsErrorMessage(os_error_message);
476 TEMP_FAILURE_RETRY(close(read_in[0])); 478 TEMP_FAILURE_RETRY(close(read_in[0]));
477 TEMP_FAILURE_RETRY(close(read_in[1])); 479 TEMP_FAILURE_RETRY(close(read_in[1]));
478 TEMP_FAILURE_RETRY(close(read_err[0])); 480 TEMP_FAILURE_RETRY(close(read_err[0]));
479 TEMP_FAILURE_RETRY(close(read_err[1])); 481 TEMP_FAILURE_RETRY(close(read_err[1]));
480 TEMP_FAILURE_RETRY(close(write_out[0])); 482 TEMP_FAILURE_RETRY(close(write_out[0]));
481 TEMP_FAILURE_RETRY(close(write_out[1])); 483 TEMP_FAILURE_RETRY(close(write_out[1]));
482 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); 484 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
483 return errno; 485 return errno;
484 } 486 }
487 FDUtils::SetCloseOnExec(event_fds[0]);
488 FDUtils::SetCloseOnExec(event_fds[1]);
485 489
486 ProcessInfoList::AddProcess(pid, event_fds[1]); 490 ProcessInfoList::AddProcess(pid, event_fds[1]);
487 *exit_event = event_fds[0]; 491 *exit_event = event_fds[0];
488 FDUtils::SetNonBlocking(event_fds[0]); 492 FDUtils::SetNonBlocking(event_fds[0]);
489 493
490 // Notify child process to start. 494 // Notify child process to start.
491 char msg = '1'; 495 char msg = '1';
492 result = FDUtils::WriteToBlocking(read_in[1], &msg, sizeof(msg)); 496 result = FDUtils::WriteToBlocking(read_in[1], &msg, sizeof(msg));
493 if (result != sizeof(msg)) { 497 if (result != sizeof(msg)) {
494 perror("Failed sending notification message"); 498 perror("Failed sending notification message");
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 559
556 560
557 void Process::TerminateExitCodeHandler() { 561 void Process::TerminateExitCodeHandler() {
558 ExitCodeHandler::TerminateExitCodeThread(); 562 ExitCodeHandler::TerminateExitCodeThread();
559 } 563 }
560 564
561 565
562 intptr_t Process::CurrentProcessId() { 566 intptr_t Process::CurrentProcessId() {
563 return static_cast<intptr_t>(getpid()); 567 return static_cast<intptr_t>(getpid());
564 } 568 }
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698