Here is the revised patch. --- surf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/surf.c b/surf.c index 2b54e3c..4ce8fdf 100644 --- a/surf.c +++ b/surf.c @@ -315,10 +315,21 @@ setup(void) GIOChannel *gchanin; GdkDisplay *gdpy; int i, j; + struct sigaction sa; + + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + + sa.sa_handler = sigchld; /* clean up any zombies immediately */ - sigchld(0); - if (signal(SIGHUP, sighup) == SIG_ERR) + if (sigaction(SIGCHLD, &sa, NULL) == -1) + die("Can't install SIGCHLD handler"); + + sa.sa_handler = sighup; + + if (sigaction(SIGHUP, &sa, NULL) == -1) die("Can't install SIGHUP handler"); if (!(dpy = XOpenDisplay(NULL))) @@ -402,8 +413,6 @@ setup(void) void sigchld(int unused) { - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("Can't install SIGCHLD handler"); while (waitpid(-1, NULL, WNOHANG) > 0) ; } -- 2.29.0