Revert "move sigchld() into XWayland section"

This reverts commit 0ddde0c85a46370759e85f3437e3475b569d5c41.

and fix build with XWayland disabled
This commit is contained in:
Leonardo Hernández Hernández 2022-12-05 20:41:48 -06:00 committed by Leonardo Hernández Hernández
parent 2d1a40caf2
commit 159670c3a2
No known key found for this signature in database
GPG Key ID: E538897EE11B9624

42
dwl.c
View File

@ -302,6 +302,7 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
static void sigchld(int unused);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
@ -403,7 +404,6 @@ static void configurex11(struct wl_listener *listener, void *data);
static void createnotifyx11(struct wl_listener *listener, void *data);
static Atom getatom(xcb_connection_t *xc, const char *name);
static void sethints(struct wl_listener *listener, void *data);
static void sigchld(int unused);
static void xwaylandready(struct wl_listener *listener, void *data);
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
static struct wl_listener xwayland_ready = {.notify = xwaylandready};
@ -2339,6 +2339,28 @@ setup(void)
#endif
}
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
* setting our own disposition for SIGCHLD.
*/
if (signal(SIGCHLD, sigchld) == SIG_ERR)
die("can't install SIGCHLD handler:");
/* 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
#ifdef XWAYLAND
&& (!xwayland || in.si_pid != xwayland->server->pid)
#endif
)
waitpid(in.si_pid, NULL, 0);
}
void
spawn(const Arg *arg)
{
@ -2782,24 +2804,6 @@ sethints(struct wl_listener *listener, void *data)
}
}
void
sigchld(int unused)
{
siginfo_t in;
/* We should be able to remove this function in favor of a simple
* struct sigaction sa = {.sa_handler = SIG_IGN};
* sigaction(SIGCHLD, &sa, NULL);
* but the Xwayland implementation in wlroots currently prevents us from
* setting our own disposition for SIGCHLD.
*/
/* 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
&& (!xwayland || in.si_pid != xwayland->server->pid))
waitpid(in.si_pid, NULL, 0);
}
void
xwaylandready(struct wl_listener *listener, void *data)
{