From 7d8413d9628ed493790454410a28b9f0c41444e6 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Wed, 1 Aug 2018 23:21:29 +1000 Subject: Reset signal mask after fork wlroots uses wl_event_loop_add_signal to handle SIGUSR1 from Xwayland. wl_event_loop_add_signal works by masking the signal and receiving it from a signalfd. The signal mask is preserved across fork and exec, so subprocesses spawned by Sway start with SIGUSR1 masked. Most subprocesses do not expect this and never unmask the signal, resulting in missing functionality or unexpected behavior for processes that use SIGUSR1 (such as i3status). Fix this by unmasking all signals between fork and exec. --- sway/commands/exec_always.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sway/commands/exec_always.c') diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 9bf2b320..c730cb8b 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "sway/commands.h" #include "sway/config.h" #include "sway/tree/container.h" @@ -47,6 +48,9 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { if ((pid = fork()) == 0) { // Fork child process again setsid(); + sigset_t set; + sigemptyset(&set); + sigprocmask(SIG_SETMASK, &set, NULL); close(fd[0]); if ((child = fork()) == 0) { close(fd[1]); -- cgit v1.2.3-54-g00ecf