init: reap exited child processes on signal_init

If any child processes exit before signal_init, they won't get reaped
unless another child process exits after signal_init.  Calling
handle_signal from signal_init forces them to be reaped immediately.

Change-Id: I459cfbfe6cf00f29454c62a8c840baf21cb1fb03
diff --git a/init/signal_handler.c b/init/signal_handler.c
index b16eef1..e5d308d 100644
--- a/init/signal_handler.c
+++ b/init/signal_handler.c
@@ -36,29 +36,6 @@
     write(signal_fd, &s, 1);
 }
 
-void signal_init(void)
-{
-    int s[2];
-
-    struct sigaction act;
-
-    act.sa_handler = sigchld_handler;
-    act.sa_flags = SA_NOCLDSTOP;
-    act.sa_mask = 0;
-    act.sa_restorer = NULL;
-    sigaction(SIGCHLD, &act, 0);
-
-    /* create a signalling mechanism for the sigchld handler */
-    if (socketpair(AF_UNIX, SOCK_STREAM, 0, s) == 0) {
-        signal_fd = s[0];
-        signal_recv_fd = s[1];
-        fcntl(s[0], F_SETFD, FD_CLOEXEC);
-        fcntl(s[0], F_SETFL, O_NONBLOCK);
-        fcntl(s[1], F_SETFD, FD_CLOEXEC);
-        fcntl(s[1], F_SETFL, O_NONBLOCK);
-    }
-}
-
 #define CRITICAL_CRASH_THRESHOLD    4       /* if we crash >4 times ... */
 #define CRITICAL_CRASH_WINDOW       (4*60)  /* ... in 4 minutes, goto recovery*/
 
@@ -149,6 +126,31 @@
         ;
 }
 
+void signal_init(void)
+{
+    int s[2];
+
+    struct sigaction act;
+
+    act.sa_handler = sigchld_handler;
+    act.sa_flags = SA_NOCLDSTOP;
+    act.sa_mask = 0;
+    act.sa_restorer = NULL;
+    sigaction(SIGCHLD, &act, 0);
+
+    /* create a signalling mechanism for the sigchld handler */
+    if (socketpair(AF_UNIX, SOCK_STREAM, 0, s) == 0) {
+        signal_fd = s[0];
+        signal_recv_fd = s[1];
+        fcntl(s[0], F_SETFD, FD_CLOEXEC);
+        fcntl(s[0], F_SETFL, O_NONBLOCK);
+        fcntl(s[1], F_SETFD, FD_CLOEXEC);
+        fcntl(s[1], F_SETFL, O_NONBLOCK);
+    }
+
+    handle_signal();
+}
+
 int get_signal_fd()
 {
     return signal_recv_fd;