mirror of
https://github.com/swaywm/sway.git
synced 2024-11-11 21:14:10 +01:00
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.
This commit is contained in:
parent
d6095588a1
commit
7d8413d962
@ -4,6 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/tree/container.h"
|
#include "sway/tree/container.h"
|
||||||
@ -47,6 +48,9 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
|||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
// Fork child process again
|
// Fork child process again
|
||||||
setsid();
|
setsid();
|
||||||
|
sigset_t set;
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigprocmask(SIG_SETMASK, &set, NULL);
|
||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
if ((child = fork()) == 0) {
|
if ((child = fork()) == 0) {
|
||||||
close(fd[1]);
|
close(fd[1]);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <signal.h>
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
@ -175,6 +176,9 @@ void invoke_swaybar(struct bar_config *bar) {
|
|||||||
if (bar->pid == 0) {
|
if (bar->pid == 0) {
|
||||||
setpgid(0, 0);
|
setpgid(0, 0);
|
||||||
close(filedes[0]);
|
close(filedes[0]);
|
||||||
|
sigset_t set;
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigprocmask(SIG_SETMASK, &set, NULL);
|
||||||
|
|
||||||
// run custom swaybar
|
// run custom swaybar
|
||||||
size_t len = snprintf(NULL, 0, "%s -b %s",
|
size_t len = snprintf(NULL, 0, "%s -b %s",
|
||||||
|
Loading…
Reference in New Issue
Block a user