~ruther/dwl

e08bd1292288f662eb265461a8c1a9d7501b0445 — Devin J. Pohly 3 years ago 7018ed9
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.
1 files changed, 7 insertions(+), 2 deletions(-)

M dwl.c
M dwl.c => dwl.c +7 -2
@@ 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

Do not follow this link