diff 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
line wrap: on
line diff
--- a/src/readpst.c	Fri Dec 24 19:26:05 2010 -0800
+++ b/src/readpst.c	Sat Apr 16 10:09:28 2011 -0700
@@ -156,9 +156,15 @@
         //fflush(stdout);
         int i,j;
         for (i=0; i<active_children; i++) {
+            int status;
             pid_t child = child_processes[i];
-            pid_t ch = waitpid(child, NULL, ((waitall) ? 0 : WNOHANG));
+            pid_t ch = waitpid(child, &status, ((waitall) ? 0 : WNOHANG));
             if (ch == child) {
+                // check termination status
+                if (WIFSIGNALED(status)) {
+                    int sig = WTERMSIG(status);
+                    DEBUG_INFO(("Process %d terminated with signal %d\n", child, sig));
+                }
                 // this has terminated, remove it from the list
                 for (j=i; j<active_children-1; j++) {
                     child_processes[j] = child_processes[j+1];