aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--swaybar/bar.c2
-rw-r--r--swaybar/status_line.c11
2 files changed, 9 insertions, 4 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 15eab782..18b87e6d 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -172,7 +172,7 @@ bool determine_bar_visibility(struct swaybar *bar, bool moving_layer) {
172 if (bar->status) { 172 if (bar->status) {
173 sway_log(SWAY_DEBUG, "Sending %s signal to status command", 173 sway_log(SWAY_DEBUG, "Sending %s signal to status command",
174 visible ? "cont" : "stop"); 174 visible ? "cont" : "stop");
175 kill(bar->status->pid, visible ? 175 kill(-bar->status->pid, visible ?
176 bar->status->cont_signal : bar->status->stop_signal); 176 bar->status->cont_signal : bar->status->stop_signal);
177 } 177 }
178 } 178 }
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) {
157 assert(!getenv("WAYLAND_SOCKET") && "display must be initialized before " 157 assert(!getenv("WAYLAND_SOCKET") && "display must be initialized before "
158 " starting `status-command`; WAYLAND_SOCKET should not be set"); 158 " starting `status-command`; WAYLAND_SOCKET should not be set");
159 status->pid = fork(); 159 status->pid = fork();
160 if (status->pid == 0) { 160 if (status->pid < 0) {
161 sway_log_errno(SWAY_ERROR, "fork failed");
162 exit(1);
163 } else if (status->pid == 0) {
164 setpgid(0, 0);
165
161 dup2(pipe_read_fd[1], STDOUT_FILENO); 166 dup2(pipe_read_fd[1], STDOUT_FILENO);
162 close(pipe_read_fd[0]); 167 close(pipe_read_fd[0]);
163 close(pipe_read_fd[1]); 168 close(pipe_read_fd[1]);
@@ -185,8 +190,8 @@ struct status_line *status_line_init(char *cmd) {
185 190
186void status_line_free(struct status_line *status) { 191void status_line_free(struct status_line *status) {
187 status_line_close_fds(status); 192 status_line_close_fds(status);
188 kill(status->pid, status->cont_signal); 193 kill(-status->pid, status->cont_signal);
189 kill(status->pid, SIGTERM); 194 kill(-status->pid, SIGTERM);
190 waitpid(status->pid, NULL, 0); 195 waitpid(status->pid, NULL, 0);
191 if (status->protocol == PROTOCOL_I3BAR) { 196 if (status->protocol == PROTOCOL_I3BAR) {
192 struct i3bar_block *block, *tmp; 197 struct i3bar_block *block, *tmp;