On Sat 12 Aug 2023 at 15:22:56 +0200, Rhialto wrote: > Or, alternatively, a proper signal handler for SIGCHLD could be set up.
I propose something like this. It worked for me in a quick test, also when I changed the style of my .xinitrc file from my usual xterm & exec ctwm to ctwm & exec xterm Before the fix, the second form did indeed cause ctwm to get blocked. === modified file 'signals.c' --- old/signals.c 2018-11-18 22:08:49 +0000 +++ new/signals.c 2023-08-12 13:44:27 +0000 @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <sys/wait.h> #include "ctwm_shutdown.h" #include "signals.h" @@ -16,6 +17,7 @@ /* Our backends */ static void sh_restart(int signum); static void sh_shutdown(int signum); +static void sh_sigchld(int signum); // Internal flags for which signals have called us @@ -46,9 +48,8 @@ // die... signal(SIGALRM, SIG_IGN); - // This should be set by default, but just in case; explicitly don't - // leave zombies. - signal(SIGCHLD, SIG_IGN); + // Explicitly don't leave zombies. + signal(SIGCHLD, sh_sigchld); return; } @@ -123,3 +124,15 @@ SignalFlag = sig_shutdown = true; } +/** + * Handle SIGCHLD so we don't leave zombie child processes. + */ +static void +sh_sigchld(int signum) +{ + pid_t pid; + int status; + + while((pid = waitpid(-1, &status, WNOHANG)) > 0) + ; +} -Olaf. -- ___ Olaf 'Rhialto' Seibert <rhialto/at/falu.nl> \X/ There is no AI. There is just someone else's work. --I. Rose
signature.asc
Description: PGP signature