]> git.itanic.dy.fi Git - rrdd/commitdiff
process: sigchild_handler: Only call waitpid()
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 15 Apr 2012 19:03:21 +0000 (22:03 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 15 Apr 2012 19:03:21 +0000 (22:03 +0300)
Calling any *printf* functions from a signal handler is unsafe. If the
interrupted process happened to be in the middle of a printf call
during the arrival of the signal, the signal handler can freeze
silently.

To avoid this, the sigchild handler will no longer call
harvest_zombies() to clear out the zombie processes. This hides the
exit status of the process, but that is not that significant
information.

An alternative way would be to simply do nothing in the signal handler
except set some flag indicating the death of a child. The signal would
cause the epoll_wait to fail with EINTR error that can be used to
trigger waitpid.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
process.c

index ac43a34a27e19458ffec9f94a8cd7a2e4df6696e..d37435779ce1a4c0971e0e128e221938d9ca5476 100644 (file)
--- a/process.c
+++ b/process.c
@@ -28,8 +28,9 @@ int get_parent_count(void)
 
 static void sigchild_handler(int signal)
 {
-       pr_info("Child has died, go harvest the zombie\n");
-       harvest_zombies(0);
+       int status;
+
+       waitpid(0, &status, 0);
 }
 
 static int setup_sigchild_handler(void)