aboutsummaryrefslogtreecommitdiff
path: root/Foundation
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-02-17 00:30:17 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-02-17 00:30:17 +0000
commit72bd0c479793ffcd5a78696da9ba27e8b26c8e3e (patch)
tree7a3761ce75ce0c4c8526baf94a9b1caea30d1cd6 /Foundation
parentcccf7ac1715ec17045c6b55f90920c847a9cd312 (diff)
[Author: dmaclach]
Fix up case where we were picking up an invalid errno value when the child process was exiting with a bad exit status. TBR=thomasvl DELTA=9 (3 added, 0 deleted, 6 changed)
Diffstat (limited to 'Foundation')
-rw-r--r--Foundation/GTMServiceManagement.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/Foundation/GTMServiceManagement.c b/Foundation/GTMServiceManagement.c
index 564358d..de84ef9 100644
--- a/Foundation/GTMServiceManagement.c
+++ b/Foundation/GTMServiceManagement.c
@@ -436,7 +436,7 @@ static int open_devnull(int fd) {
void spc_sanitize_files(void) {
int standard_fds[] = { STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO };
- int standard_fds_count
+ int standard_fds_count
= (int)(sizeof(standard_fds) / sizeof(standard_fds[0]));
// Make sure all open descriptors other than the standard ones are closed
@@ -557,14 +557,17 @@ Boolean GTMSMJobSubmit(CFDictionaryRef cf_job, CFErrorRef *error) {
do {
pid = waitpid(childpid, &status, 0);
} while (pid == -1 && errno == EINTR);
- if (pid == -1 || WEXITSTATUS(status)) {
+ if (pid == -1) {
local_error
= GTMCFLaunchCreateUnlocalizedError(errno,
- CFSTR("Child Process Error.\n"
- "Cmd: /bin/launchctl\n"
- "pid: %d\n"
- "ExitStatus: %d\n"),
- childpid, WEXITSTATUS(status));
+ CFSTR("waitpid failed."));
+ goto exit;
+ } else if (WEXITSTATUS(status)) {
+ local_error
+ = GTMCFLaunchCreateUnlocalizedError(ECHILD,
+ CFSTR("Child exit status: %d "
+ "pid: %d"),
+ WEXITSTATUS(status), childpid);
goto exit;
}
} else {