[dev] [PATCH] dwm -- Proper SIGCHLD usage , fix issue with uncollected processes

From: Premysl 'Anydot' Hruby <dfenze_AT_gmail.com>
Date: Tue, 11 Aug 2009 23:43:58 +0200

This is much cleaner and portable way of using SIGCHLD. It also disallow
existence of defunct processes, one which are executed for example from
.Xsession before (on the end) exec /path/../dwm

---
 dwm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dwm.c b/dwm.c
index 873b794..3cb4a8e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -207,7 +207,7 @@ static void setlayout(const Arg *arg);
 static void setmfact(const Arg *arg);
 static void setup(void);
 static void showhide(Client *c);
-static void sigchld(int signal);
+static void sigchld(int unused);
 static void spawn(const Arg *arg);
 static void tag(const Arg *arg);
 static void tagmon(const Arg *arg);
@@ -1428,6 +1428,8 @@ setup(void) {
 	int w;
 	XSetWindowAttributes wa;
 
+	signal(SIGCHLD, sigchld);
+
 	/* init screen */
 	screen = DefaultScreen(dpy);
 	root = RootWindow(dpy, screen);
@@ -1496,13 +1498,13 @@ showhide(Client *c) {
 
 
 void
-sigchld(int signal) {
+sigchld(int unusedl) {
 	while(0 < waitpid(-1, NULL, WNOHANG));
+	signal(SIGCHLD, sigchld);
 }
 
 void
 spawn(const Arg *arg) {
-	signal(SIGCHLD, sigchld);
 	if(fork() == 0) {
 		if(dpy)
 			close(ConnectionNumber(dpy));
-- 
1.6.3.3
Received on Tue Aug 11 2009 - 21:43:58 UTC

This archive was generated by hypermail 2.2.0 : Sun Aug 16 2009 - 14:18:42 UTC