| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 <signal.h> | 9 #include <signal.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 | 86 |
| 87 void ExitHandler(int process_signal, siginfo_t* siginfo, void* tmp) { | 87 void ExitHandler(int process_signal, siginfo_t* siginfo, void* tmp) { |
| 88 int pid = 0; | 88 int pid = 0; |
| 89 int status = 0; | 89 int status = 0; |
| 90 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { | 90 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { |
| 91 int exit_code = 0; | 91 int exit_code = 0; |
| 92 int negative = 0; | 92 int negative = 0; |
| 93 if (WIFEXITED(status)) { | 93 if (WIFEXITED(status)) { |
| 94 exit_code = WEXITSTATUS(status); | 94 exit_code = WEXITSTATUS(status); |
| 95 if (exit_code == 255) { | |
| 96 exit_code = 1; | |
| 97 negative = 1; | |
| 98 } | |
| 99 } | 95 } |
| 100 if (WIFSIGNALED(status)) { | 96 if (WIFSIGNALED(status)) { |
| 101 exit_code = WTERMSIG(status); | 97 exit_code = WTERMSIG(status); |
| 102 negative = 1; | 98 negative = 1; |
| 103 } | 99 } |
| 104 ProcessInfo* process = LookupProcess(pid); | 100 ProcessInfo* process = LookupProcess(pid); |
| 105 if (process != NULL) { | 101 if (process != NULL) { |
| 106 int message[3] = { pid, exit_code, negative }; | 102 int message[3] = { pid, exit_code, negative }; |
| 107 intptr_t result = | 103 intptr_t result = |
| 108 FDUtils::WriteToBlocking(process->fd(), &message, sizeof(message)); | 104 FDUtils::WriteToBlocking(process->fd(), &message, sizeof(message)); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 if (result == -1) { | 345 if (result == -1) { |
| 350 return false; | 346 return false; |
| 351 } | 347 } |
| 352 return true; | 348 return true; |
| 353 } | 349 } |
| 354 | 350 |
| 355 | 351 |
| 356 void Process::Exit(intptr_t id) { | 352 void Process::Exit(intptr_t id) { |
| 357 RemoveProcess(id); | 353 RemoveProcess(id); |
| 358 } | 354 } |
| OLD | NEW |