Mercurial > libpst
comparison src/readpst.c @ 258:8ad8fd1c5451
check return codes from forked processes
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sat, 16 Apr 2011 10:09:28 -0700 |
parents | c947b8812120 |
children | 78e95fab9a8b |
comparison
equal
deleted
inserted
replaced
257:c947b8812120 | 258:8ad8fd1c5451 |
---|---|
154 sem_getvalue(global_children, &available); | 154 sem_getvalue(global_children, &available); |
155 //printf("grim reaper %s for pid %d (parent %d) with %d children, %d available\n", (waitall) ? "all" : "", getpid(), getppid(), active_children, available); | 155 //printf("grim reaper %s for pid %d (parent %d) with %d children, %d available\n", (waitall) ? "all" : "", getpid(), getppid(), active_children, available); |
156 //fflush(stdout); | 156 //fflush(stdout); |
157 int i,j; | 157 int i,j; |
158 for (i=0; i<active_children; i++) { | 158 for (i=0; i<active_children; i++) { |
159 int status; | |
159 pid_t child = child_processes[i]; | 160 pid_t child = child_processes[i]; |
160 pid_t ch = waitpid(child, NULL, ((waitall) ? 0 : WNOHANG)); | 161 pid_t ch = waitpid(child, &status, ((waitall) ? 0 : WNOHANG)); |
161 if (ch == child) { | 162 if (ch == child) { |
163 // check termination status | |
164 if (WIFSIGNALED(status)) { | |
165 int sig = WTERMSIG(status); | |
166 DEBUG_INFO(("Process %d terminated with signal %d\n", child, sig)); | |
167 } | |
162 // this has terminated, remove it from the list | 168 // this has terminated, remove it from the list |
163 for (j=i; j<active_children-1; j++) { | 169 for (j=i; j<active_children-1; j++) { |
164 child_processes[j] = child_processes[j+1]; | 170 child_processes[j] = child_processes[j+1]; |
165 } | 171 } |
166 active_children--; | 172 active_children--; |