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

Unified Diff: runtime/bin/process_linux.cc

Issue 8506009: Avoid creating zombie processes by waiting for the terminated process. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 | « no previous file | 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 28986be8037d8eee73ab7ed384ce3533095593db..114dcd184e8ccea3690fcf228142bb1043bef80c 100644
--- a/runtime/bin/process_linux.cc
+++ b/runtime/bin/process_linux.cc
@@ -2,17 +2,18 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#include "bin/process.h"
+
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/wait.h>
#include <unistd.h>
#include "bin/fdutils.h"
-#include "bin/process.h"
-
class ProcessInfo {
public:
@@ -94,6 +95,11 @@ void ExitHandler(int process_signal, siginfo_t* siginfo, void* tmp) {
}
ProcessInfo* process = LookupProcess(siginfo->si_pid);
if (process != NULL) {
+ int status = 0;
+ int wait_result = waitpid(siginfo->si_pid, &status, WNOHANG);
+ if (wait_result == -1 || wait_result == 0) {
+ perror("ExitHandler waitpid failed");
+ }
intptr_t message[2] = { siginfo->si_pid, siginfo->si_status };
intptr_t result =
FDUtils::WriteToBlocking(process->fd(), &message, sizeof(message));
« no previous file with comments | « no previous file | runtime/bin/process_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698