From b46b7e962f5b657d280f3e607dd12d60fa1db84a Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 4 Feb 2023 12:57:26 +0100 Subject: [PATCH] apply latest suckless commit --- Makefile | 4 ++++ speedwm.c | 51 ++++++++++++++++++++++++--------------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 0135b1b..1984370 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,11 @@ speedwm: ${OBJ} ifdef USESTATUS status: status.o + cp status.h status.def.h + [ -f "status.rl.h" ] && cp status.rl.h status.h || : $(CC) status.o $(CFLAGS) $(LDFLAGS) -o speedwm_status + mv status.def.h status.h + chmod 0777 status.h status.o: status.c status.h $(CC) -c status.c endif diff --git a/speedwm.c b/speedwm.c index dac77c3..288ab60 100644 --- a/speedwm.c +++ b/speedwm.c @@ -639,7 +639,6 @@ static void hideall(const Arg *arg); static void showwin(Client *c); static void showhide(Client *c); -static void sigchld(int unused); #ifdef XINERAMA static void sortscreens(XineramaScreenInfo *screens, int n); #endif @@ -5127,11 +5126,31 @@ setup(void) { XSetWindowAttributes wa; Atom utf8string; + struct sigaction sa; + pid_t pid; - /* clean up any zombies immediately */ - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("can't install SIGCHLD handler:"); - sigchld(0); + /* do not transform children into zombies when they terminate */ + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART; + sa.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &sa, NULL); + + /* clean up any zombies (inherited from .xinitrc etc) immediately */ + while ((pid = waitpid(-1, NULL, WNOHANG) > 0)) { + pid_t *p, *lim; + + if (!(p = autostart_pids)) + continue; + lim = &p[autostart_len]; + + for (; p < lim; p++) { + if (*p == pid) { + *p = -1; + break; + } + } + + } signal(SIGHUP, sighup); signal(SIGTERM, sigterm); @@ -5326,28 +5345,6 @@ reloadcolors(const Arg *arg) } #endif -void -sigchld(int unused) -{ - pid_t pid; - - while (0 < (pid = waitpid(-1, NULL, WNOHANG))) { - pid_t *p, *lim; - - if (!(p = autostart_pids)) - continue; - lim = &p[autostart_len]; - - for (; p < lim; p++) { - if (*p == pid) { - *p = -1; - break; - } - } - - } -} - void sighup(int unused) {