aboutsummaryrefslogtreecommitdiff
path: root/swaybar/status_line.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/status_line.c')
-rw-r--r--swaybar/status_line.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/swaybar/status_line.c b/swaybar/status_line.c
index ecd91032..a97f3525 100644
--- a/swaybar/status_line.c
+++ b/swaybar/status_line.c
@@ -157,7 +157,12 @@ struct status_line *status_line_init(char *cmd) {
assert(!getenv("WAYLAND_SOCKET") && "display must be initialized before "
" starting `status-command`; WAYLAND_SOCKET should not be set");
status->pid = fork();
- if (status->pid == 0) {
+ if (status->pid < 0) {
+ sway_log_errno(SWAY_ERROR, "fork failed");
+ exit(1);
+ } else if (status->pid == 0) {
+ setpgid(0, 0);
+
dup2(pipe_read_fd[1], STDOUT_FILENO);
close(pipe_read_fd[0]);
close(pipe_read_fd[1]);
@@ -185,8 +190,8 @@ struct status_line *status_line_init(char *cmd) {
void status_line_free(struct status_line *status) {
status_line_close_fds(status);
- kill(status->pid, status->cont_signal);
- kill(status->pid, SIGTERM);
+ kill(-status->pid, status->cont_signal);
+ kill(-status->pid, SIGTERM);
waitpid(status->pid, NULL, 0);
if (status->protocol == PROTOCOL_I3BAR) {
struct i3bar_block *block, *tmp;