diff options
Diffstat (limited to 'swaybar/status_line.c')
-rw-r--r-- | swaybar/status_line.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/swaybar/status_line.c b/swaybar/status_line.c index ecd91032..2e9bb7f1 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c | |||
@@ -117,11 +117,11 @@ bool status_handle_readable(struct status_line *status) { | |||
117 | status->text = status->buffer; | 117 | status->text = status->buffer; |
118 | // intentional fall-through | 118 | // intentional fall-through |
119 | case PROTOCOL_TEXT: | 119 | case PROTOCOL_TEXT: |
120 | errno = 0; | ||
121 | while (true) { | 120 | while (true) { |
122 | if (status->buffer[read_bytes - 1] == '\n') { | 121 | if (status->buffer[read_bytes - 1] == '\n') { |
123 | status->buffer[read_bytes - 1] = '\0'; | 122 | status->buffer[read_bytes - 1] = '\0'; |
124 | } | 123 | } |
124 | errno = 0; | ||
125 | read_bytes = getline(&status->buffer, | 125 | read_bytes = getline(&status->buffer, |
126 | &status->buffer_size, status->read); | 126 | &status->buffer_size, status->read); |
127 | if (errno == EAGAIN) { | 127 | if (errno == EAGAIN) { |
@@ -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 | ||
186 | void status_line_free(struct status_line *status) { | 191 | void 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; |