From cf0ec46073e93ec29662643a25d328736b215791 Mon Sep 17 00:00:00 2001 From: danw Date: Mon, 9 Nov 1998 22:48:18 +0000 Subject: [PATCH] listen for SIGCHLDs to avoid zombies --- update/update_server.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/update/update_server.c b/update/update_server.c index d93a5dbd..a0832e6b 100644 --- a/update/update_server.c +++ b/update/update_server.c @@ -11,12 +11,14 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -33,6 +35,8 @@ int have_authorization = 0; des_cblock session; int uid = 0; +void child_handler(int signal); + struct _dt { char *str; void (*proc)(int, char *); @@ -52,6 +56,7 @@ int main(int argc, char **argv) struct _dt *d; struct utsname name; int s, conn; + struct sigaction sa; whoami = strrchr(argv[0], '/'); if (whoami) @@ -79,6 +84,11 @@ int main(int argc, char **argv) umask(0022); mr_init(); + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + sa.sa_handler = child_handler; + sigaction(SIGCHLD, &sa, NULL); + /* If the config file contains a line "user username", the * daemon will run with that user's UID. */ @@ -210,3 +220,11 @@ void fail(int conn, int err, char *msg) close(conn); exit(1); } + +void child_handler(int signal) +{ + int status; + + while (waitpid(-1, &status, WNOHANG) > 0) + ; +} -- 2.45.2