summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2003-08-04 18:27:27 +0000
committerWayne Davison <wayned@samba.org>2003-08-04 18:27:27 +0000
commitca20c7fd625c27f540b0ae5be027cb51700c80e3 (patch)
tree0d331740431adc42eb7d8b058e2c18e9b42d1ee8
parent191e40da17f9139cb702c48a7d708a4563ccc0c2 (diff)
downloadrsync-ca20c7fd625c27f540b0ae5be027cb51700c80e3.tar.gz
Instead of ignoring SIG_CHLD, reap zombies in the signal handler.
-rw-r--r--socket.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/socket.c b/socket.c
index eb0660bb..cb15441f 100644
--- a/socket.c
+++ b/socket.c
@@ -374,6 +374,14 @@ int is_a_socket(int fd)
}
+static RETSIGTYPE sigchld_handler(int UNUSED(val)) {
+ signal(SIGCHLD, sigchld_handler);
+#ifdef WNOHANG
+ while (waitpid(-1, NULL, WNOHANG) > 0) {}
+#endif
+}
+
+
void start_accept_loop(int port, int (*fn)(int, int))
{
int s;
@@ -419,14 +427,7 @@ void start_accept_loop(int port, int (*fn)(int, int))
if (fd == -1) continue;
- signal(SIGCHLD, SIG_IGN);
-
- /* we shouldn't have any children left hanging around
- but I have had reports that on Digital Unix zombies
- are produced, so this ensures that they are reaped */
-#ifdef WNOHANG
- while (waitpid(-1, NULL, WNOHANG) > 0);
-#endif
+ signal(SIGCHLD, sigchld_handler);
if ((pid = fork()) == 0) {
int ret;