aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Marien Zwart <marienz@google.com>2018-08-01 23:21:29 +1000
committerLibravatar Marien Zwart <marienz@google.com>2018-08-02 21:31:34 +1000
commit7d8413d9628ed493790454410a28b9f0c41444e6 (patch)
tree30f1998285da49fdf3bfe37b29c8c046b8095071
parentLink xcb dependency to meson options "enable_xwayland" (#2393) (diff)
downloadsway-7d8413d9628ed493790454410a28b9f0c41444e6.tar.gz
sway-7d8413d9628ed493790454410a28b9f0c41444e6.tar.zst
sway-7d8413d9628ed493790454410a28b9f0c41444e6.zip
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.
-rw-r--r--sway/commands/exec_always.c4
-rw-r--r--sway/config/bar.c4
2 files changed, 8 insertions, 0 deletions
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 @@
4#include <string.h> 4#include <string.h>
5#include <sys/wait.h> 5#include <sys/wait.h>
6#include <unistd.h> 6#include <unistd.h>
7#include <signal.h>
7#include "sway/commands.h" 8#include "sway/commands.h"
8#include "sway/config.h" 9#include "sway/config.h"
9#include "sway/tree/container.h" 10#include "sway/tree/container.h"
@@ -47,6 +48,9 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
47 if ((pid = fork()) == 0) { 48 if ((pid = fork()) == 0) {
48 // Fork child process again 49 // Fork child process again
49 setsid(); 50 setsid();
51 sigset_t set;
52 sigemptyset(&set);
53 sigprocmask(SIG_SETMASK, &set, NULL);
50 close(fd[0]); 54 close(fd[0]);
51 if ((child = fork()) == 0) { 55 if ((child = fork()) == 0) {
52 close(fd[1]); 56 close(fd[1]);
diff --git a/sway/config/bar.c b/sway/config/bar.c
index 3a74331e..ae9383d6 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -10,6 +10,7 @@
10#include <sys/stat.h> 10#include <sys/stat.h>
11#include <signal.h> 11#include <signal.h>
12#include <strings.h> 12#include <strings.h>
13#include <signal.h>
13#include "sway/config.h" 14#include "sway/config.h"
14#include "stringop.h" 15#include "stringop.h"
15#include "list.h" 16#include "list.h"
@@ -175,6 +176,9 @@ void invoke_swaybar(struct bar_config *bar) {
175 if (bar->pid == 0) { 176 if (bar->pid == 0) {
176 setpgid(0, 0); 177 setpgid(0, 0);
177 close(filedes[0]); 178 close(filedes[0]);
179 sigset_t set;
180 sigemptyset(&set);
181 sigprocmask(SIG_SETMASK, &set, NULL);
178 182
179 // run custom swaybar 183 // run custom swaybar
180 size_t len = snprintf(NULL, 0, "%s -b %s", 184 size_t len = snprintf(NULL, 0, "%s -b %s",