make sure to leave XWayland process waitable

On SIGCHLD, check to make sure the terminated process is not the
XWayland process before reaping it, allowing wlroots to waitpid() for it
successfully.

Fixes #177.
This commit is contained in:
Devin J. Pohly 2022-03-29 15:55:06 -05:00
parent 7018ed9218
commit e08bd12922

9
dwl.c
View File

@ -1925,6 +1925,7 @@ setup(void)
void
sigchld(int unused)
{
siginfo_t in;
/* We should be able to remove this function in favor of a simple
* signal(SIGCHLD, SIG_IGN);
* but the Xwayland implementation in wlroots currently prevents us from
@ -1932,8 +1933,12 @@ sigchld(int unused)
*/
if (signal(SIGCHLD, sigchld) == SIG_ERR)
EBARF("can't install SIGCHLD handler");
while (0 < waitpid(-1, NULL, WNOHANG))
;
/* WNOWAIT leaves the child in a waitable state, in case this is the
* XWayland process
*/
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
&& in.si_pid != xwayland->server->pid)
waitpid(in.si_pid, NULL, 0);
}
void