From b9726afd485a9eca0aa7d123db1e55edb7bfc386 Mon Sep 17 00:00:00 2001 From: Geoff Greer Date: Thu, 26 Apr 2018 18:13:44 -0700 Subject: [PATCH 1/2] invoke_swaybar(): Set process group. Kill process group. Fixes a bug where terminate_swaybar() did not terminate swaybar. --- sway/config/bar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/config/bar.c b/sway/config/bar.c index 2913f059..cb9e82f8 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -17,7 +17,7 @@ static void terminate_swaybar(pid_t pid) { wlr_log(L_DEBUG, "Terminating swaybar %d", pid); - int ret = kill(pid, SIGTERM); + int ret = kill(-pid, SIGTERM); if (ret != 0) { wlr_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid); } else { @@ -163,6 +163,7 @@ void invoke_swaybar(struct bar_config *bar) { bar->pid = fork(); if (bar->pid == 0) { + setpgid(0, 0); close(filedes[0]); // run custom swaybar From 5587af1782539e2ea2c762597054a066bc0eeee7 Mon Sep 17 00:00:00 2001 From: Geoff Greer Date: Thu, 26 Apr 2018 18:16:29 -0700 Subject: [PATCH 2/2] Rename len to msg_len. Avoids an aliased variable that was a little confusing to follow. --- sway/config/bar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sway/config/bar.c b/sway/config/bar.c index cb9e82f8..5a97c3cc 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -173,9 +173,9 @@ void invoke_swaybar(struct bar_config *bar) { char *command = malloc(len + 1); if (!command) { const char msg[] = "Unable to allocate swaybar command string"; - size_t len = sizeof(msg); - if (write(filedes[1], &len, sizeof(int))) {}; - if (write(filedes[1], msg, len)) {}; + size_t msg_len = sizeof(msg); + if (write(filedes[1], &msg_len, sizeof(int))) {}; + if (write(filedes[1], msg, msg_len)) {}; close(filedes[1]); exit(1); }