Welcome to little lamb

Code » anopa » commit 0d3e5ea

start/stop: Fix possibly missing oneshot being done

author Olivier Brunel
2015-03-01 12:55:16 UTC
committer Olivier Brunel
2015-04-04 12:47:36 UTC
parent 06bf8436cd12f5e16e2e0b2b86d12a31a9d27ad1

start/stop: Fix possibly missing oneshot being done

Fix SIGCHLD handling for when we get one signal for more than one child,
which would leave anopa waiting forever.

src/anopa/start-stop.c +10 -4

diff --git a/src/anopa/start-stop.c b/src/anopa/start-stop.c
index 81b3af8..9eb052e 100644
--- a/src/anopa/start-stop.c
+++ b/src/anopa/start-stop.c
@@ -592,7 +592,8 @@ handle_oneshot (int is_start)
     r = wait_pids_nohang ((pid_t const *) ga_pid.s, genalloc_len (pid_t, &ga_pid), &wstat);
     if (r < 0)
     {
-        strerr_warnwu1sys ("wait_pids_nohang");
+        if (errno != ECHILD)
+            strerr_warnwu1sys ("wait_pids_nohang");
         return r;
     }
     else if (r == 0)
@@ -739,9 +740,14 @@ handle_signals (aa_mode mode)
 
             case SIGCHLD:
                 {
-                    int rr = handle_oneshot (mode == AA_MODE_START);
-                    if (rr > 0)
-                        r += rr;
+                    for (;;)
+                    {
+                        int rr = handle_oneshot (mode == AA_MODE_START);
+                        if (rr > 0)
+                            r += rr;
+                        else
+                            break;
+                    }
                     break;
                 }