Use SIGCHLD handler from dwm

Fixes #46.
This commit is contained in:
Devin J. Pohly 2020-08-18 18:22:44 -05:00
parent c0b05eddb8
commit d615d3836c

15
dwl.c
View file

@ -224,6 +224,7 @@ static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, unsigned int newtags); static void setmon(Client *c, Monitor *m, unsigned int newtags);
static void setup(void); static void setup(void);
static void sigchld(int unused);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
@ -1458,6 +1459,9 @@ setsel(struct wl_listener *listener, void *data)
void void
setup(void) setup(void)
{ {
/* clean up child processes immediately */
sigchld(0);
/* The backend is a wlroots feature which abstracts the underlying input and /* The backend is a wlroots feature which abstracts the underlying input and
* output hardware. The autocreate option will choose the most suitable * output hardware. The autocreate option will choose the most suitable
* backend based on the current environment, such as opening an X11 window * backend based on the current environment, such as opening an X11 window
@ -1579,6 +1583,17 @@ setup(void)
#endif #endif
} }
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 void
spawn(const Arg *arg) spawn(const Arg *arg)
{ {