From 72bd0c479793ffcd5a78696da9ba27e8b26c8e3e Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Thu, 17 Feb 2011 00:30:17 +0000 Subject: [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) --- Foundation/GTMServiceManagement.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Foundation/GTMServiceManagement.c') 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 { -- cgit v1.2.3