aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-08-18 18:22:44 -0500
committerDevin J. Pohly <djpohly@gmail.com>2020-08-18 18:22:44 -0500
commitd615d3836c8a4091a9fc7f5313e517f04df48601 (patch)
tree9036730e5be5a3daf4c18612e3f06eecaabdce9a
parentc0b05eddb8c3cca888f75eab45288802ce592431 (diff)
Use SIGCHLD handler from dwm
Fixes #46.
-rw-r--r--dwl.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index c4af87e..18c2b33 100644
--- a/dwl.c
+++ b/dwl.c
@@ -224,6 +224,7 @@ static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, unsigned int newtags);
static void setup(void);
+static void sigchld(int unused);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
@@ -1458,6 +1459,9 @@ setsel(struct wl_listener *listener, void *data)
void
setup(void)
{
+ /* clean up child processes immediately */
+ sigchld(0);
+
/* The backend is a wlroots feature which abstracts the underlying input and
* output hardware. The autocreate option will choose the most suitable
* backend based on the current environment, such as opening an X11 window
@@ -1580,6 +1584,17 @@ setup(void)
}
void
+sigchld(int unused)
+{
+ if (signal(SIGCHLD, sigchld) == SIG_ERR) {
+ perror("can't install SIGCHLD handler");
+ exit(EXIT_FAILURE);
+ }
+ while (0 < waitpid(-1, NULL, WNOHANG))
+ ;
+}
+
+void
spawn(const Arg *arg)
{
if (fork() == 0) {