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

Unified Diff: runtime/bin/process_macos.cc

Issue 9310053: Rework Windows process handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows build and add stable binaries. Created 8 years, 11 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_linux.cc ('k') | runtime/bin/process_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_macos.cc
diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc
index 13221c092d50d93e0450262b0dbc7e477837d700..c71aca369b5648eee86817e715ce297f536c3787 100644
--- a/runtime/bin/process_macos.cc
+++ b/runtime/bin/process_macos.cc
@@ -24,6 +24,12 @@
class ProcessInfo {
public:
ProcessInfo(pid_t pid, intptr_t fd) : pid_(pid), fd_(fd) { }
+ ~ProcessInfo() {
+ int closed = TEMP_FAILURE_RETRY(close(fd_));
+ if (closed != 0) {
+ FATAL("Failed to close process exit code pipe");
+ }
+ }
pid_t pid() { return pid_; }
intptr_t fd() { return fd_; }
ProcessInfo* next() { return next_; }
@@ -186,13 +192,19 @@ class ExitCodeHandler {
}
intptr_t exit_code_fd = ProcessInfoList::LookupProcessExitFd(pid);
if (exit_code_fd != 0) {
- int message[3] = { pid, exit_code, negative };
+ int message[2] = { exit_code, negative };
ssize_t result =
FDUtils::WriteToBlocking(exit_code_fd, &message, sizeof(message));
- if (result != sizeof(message) && errno != EPIPE) {
- perror("ExitHandler notification failed");
+ // If the process has been closed, the read end of the exit
+ // pipe has been closed. It is therefore not a problem that
+ // writennnj fails with a broken pipe error. Other errors should
+ // not happen.
+ if (result != -1 && result != sizeof(message)) {
+ FATAL("Failed to write entire process exit message");
+ } else if (result == -1 && errno != EPIPE) {
+ FATAL1("Failed to write exit code: %d", errno);
}
- TEMP_FAILURE_RETRY(close(exit_code_fd));
+ ProcessInfoList::RemoveProcess(pid);
}
}
}
@@ -527,11 +539,6 @@ bool Process::Kill(intptr_t id) {
}
-void Process::Exit(intptr_t id) {
- ProcessInfoList::RemoveProcess(id);
-}
-
-
void Process::TerminateExitCodeHandler() {
ExitCodeHandler::TerminateExitCodeThread();
}
« no previous file with comments | « runtime/bin/process_linux.cc ('k') | runtime/bin/process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698