Bug 160
authorSteve Singer <ssinger@ca.afilias.info>
Mon, 25 Oct 2010 19:10:22 +0000 (15:10 -0400)
committerSteve Singer <ssinger@ca.afilias.info>
Fri, 19 Nov 2010 14:57:50 +0000 (09:57 -0500)
IF wait returns pid < 0 and errno != EINTR bail because
an error occured and we don't know what else to do
(cherry picked from commit 1ce965cf3ae06fc03a2017f87eedefa6f95ddde4)

src/slon/slon.c

index 09a94edbe0ec8f48435562fcc697e613ff49240f..6085657de0eb34bfd7e60427d9f3aeda33762746 100644 (file)
@@ -912,9 +912,21 @@ SlonWatchdog(void)
                while ((pid = wait(&child_status)) != slon_worker_pid)
                {
                        if (pid < 0 && errno == EINTR)
-                               continue;
+                               continue;                       
 
-                       slon_log(SLON_CONFIG, "slon: child terminated status: %d; pid: %d, current worker pid: %d\n", child_status, pid, slon_worker_pid);
+                       slon_log(SLON_CONFIG, "slon: child terminated status: %d; pid: %d, current worker pid: %d errno: %d\n", child_status, pid, slon_worker_pid,errno);
+               
+                       if(pid < 0 )
+                       {
+                               /**
+                                * if errno is not EINTR and pid<0 we have
+                                * a problem.
+                                * looping on wait() isn't a good idea.
+                                */
+                               slon_log(SLON_FATAL,"slon: wait returned an error pid:%d errno:%d\n",
+                                                pid,errno);
+                               exit(-1);
+                       }
                }
                if( WIFSIGNALED(child_status) ) 
                {