mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
Merge branch 'master' into master
This commit is contained in:
commit
f2db75597c
5 changed files with 15 additions and 18 deletions
|
|
@ -163,6 +163,7 @@ bool server_start(struct sway_server *server);
|
||||||
void server_run(struct sway_server *server);
|
void server_run(struct sway_server *server);
|
||||||
|
|
||||||
void restore_nofile_limit(void);
|
void restore_nofile_limit(void);
|
||||||
|
void restore_signals(void);
|
||||||
|
|
||||||
void handle_new_output(struct wl_listener *listener, void *data);
|
void handle_new_output(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,8 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) {
|
||||||
pid_t child = fork();
|
pid_t child = fork();
|
||||||
if (child == 0) {
|
if (child == 0) {
|
||||||
restore_nofile_limit();
|
restore_nofile_limit();
|
||||||
|
restore_signals();
|
||||||
setsid();
|
setsid();
|
||||||
sigset_t set;
|
|
||||||
sigemptyset(&set);
|
|
||||||
sigprocmask(SIG_SETMASK, &set, NULL);
|
|
||||||
signal(SIGPIPE, SIG_DFL);
|
|
||||||
|
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
const char *token = launcher_ctx_get_token_name(ctx);
|
const char *token = launcher_ctx_get_token_name(ctx);
|
||||||
|
|
|
||||||
|
|
@ -213,13 +213,8 @@ static void invoke_swaybar(struct bar_config *bar) {
|
||||||
sway_log(SWAY_ERROR, "Failed to create fork for swaybar");
|
sway_log(SWAY_ERROR, "Failed to create fork for swaybar");
|
||||||
return;
|
return;
|
||||||
} else if (pid == 0) {
|
} else if (pid == 0) {
|
||||||
// Remove the SIGUSR1 handler that wlroots adds for xwayland
|
|
||||||
sigset_t set;
|
|
||||||
sigemptyset(&set);
|
|
||||||
sigprocmask(SIG_SETMASK, &set, NULL);
|
|
||||||
signal(SIGPIPE, SIG_DFL);
|
|
||||||
|
|
||||||
restore_nofile_limit();
|
restore_nofile_limit();
|
||||||
|
restore_signals();
|
||||||
if (!sway_set_cloexec(sockets[1], false)) {
|
if (!sway_set_cloexec(sockets[1], false)) {
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1061,6 +1061,7 @@ static bool _spawn_swaybg(char **command) {
|
||||||
return false;
|
return false;
|
||||||
} else if (pid == 0) {
|
} else if (pid == 0) {
|
||||||
restore_nofile_limit();
|
restore_nofile_limit();
|
||||||
|
restore_signals();
|
||||||
if (!sway_set_cloexec(sockets[1], false)) {
|
if (!sway_set_cloexec(sockets[1], false)) {
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
sway/main.c
19
sway/main.c
|
|
@ -48,13 +48,6 @@ void sig_handler(int signal) {
|
||||||
sway_terminate(EXIT_SUCCESS);
|
sway_terminate(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sigchld_handler(int signal) {
|
|
||||||
pid_t pid;
|
|
||||||
do {
|
|
||||||
pid = waitpid(-1, NULL, WNOHANG);
|
|
||||||
} while (pid > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void run_as_ipc_client(char *command, char *socket_path) {
|
void run_as_ipc_client(char *command, char *socket_path) {
|
||||||
int socketfd = ipc_open_socket(socket_path);
|
int socketfd = ipc_open_socket(socket_path);
|
||||||
uint32_t len = strlen(command);
|
uint32_t len = strlen(command);
|
||||||
|
|
@ -159,6 +152,14 @@ void restore_nofile_limit(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void restore_signals(void) {
|
||||||
|
sigset_t set;
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigprocmask(SIG_SETMASK, &set, NULL);
|
||||||
|
signal(SIGCHLD, SIG_DFL);
|
||||||
|
signal(SIGPIPE, SIG_DFL);
|
||||||
|
}
|
||||||
|
|
||||||
void enable_debug_flag(const char *flag) {
|
void enable_debug_flag(const char *flag) {
|
||||||
if (strcmp(flag, "noatomic") == 0) {
|
if (strcmp(flag, "noatomic") == 0) {
|
||||||
debug.noatomic = true;
|
debug.noatomic = true;
|
||||||
|
|
@ -332,7 +333,9 @@ int main(int argc, char **argv) {
|
||||||
// handle SIGTERM signals
|
// handle SIGTERM signals
|
||||||
signal(SIGTERM, sig_handler);
|
signal(SIGTERM, sig_handler);
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
signal(SIGCHLD, sigchld_handler);
|
|
||||||
|
// avoid need to reap children
|
||||||
|
signal(SIGCHLD, SIG_IGN);
|
||||||
|
|
||||||
// prevent ipc from crashing sway
|
// prevent ipc from crashing sway
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue