aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/status_line.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-09-15 10:15:30 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-09-18 11:36:33 +0100
commit952453480f6764eb583b2507c7af83e242e0630a (patch)
treeac0b09f4190951b799940667d9ae43e7a778b44e /swaybar/status_line.c
parentswaybar: remove block links upon exit (diff)
downloadsway-952453480f6764eb583b2507c7af83e242e0630a.tar.gz
sway-952453480f6764eb583b2507c7af83e242e0630a.tar.zst
sway-952453480f6764eb583b2507c7af83e242e0630a.zip
swaybar: invalidate file descriptors upon closing
Diffstat (limited to 'swaybar/status_line.c')
-rw-r--r--swaybar/status_line.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/swaybar/status_line.c b/swaybar/status_line.c
index 688e5947..09ed2375 100644
--- a/swaybar/status_line.c
+++ b/swaybar/status_line.c
@@ -7,12 +7,24 @@
7#include <unistd.h> 7#include <unistd.h>
8#include <wlr/util/log.h> 8#include <wlr/util/log.h>
9#include "swaybar/config.h" 9#include "swaybar/config.h"
10#include "swaybar/event_loop.h"
10#include "swaybar/status_line.h" 11#include "swaybar/status_line.h"
11#include "readline.h" 12#include "readline.h"
12 13
14static void status_line_close_fds(struct status_line *status) {
15 if (status->read_fd != -1) {
16 remove_event(status->read_fd);
17 close(status->read_fd);
18 status->read_fd = -1;
19 }
20 if (status->write_fd != -1) {
21 close(status->write_fd);
22 status->write_fd = -1;
23 }
24}
25
13void status_error(struct status_line *status, const char *text) { 26void status_error(struct status_line *status, const char *text) {
14 close(status->read_fd); 27 status_line_close_fds(status);
15 close(status->write_fd);
16 status->protocol = PROTOCOL_ERROR; 28 status->protocol = PROTOCOL_ERROR;
17 status->text = text; 29 status->text = text;
18} 30}
@@ -123,8 +135,7 @@ struct status_line *status_line_init(char *cmd) {
123} 135}
124 136
125void status_line_free(struct status_line *status) { 137void status_line_free(struct status_line *status) {
126 close(status->read_fd); 138 status_line_close_fds(status);
127 close(status->write_fd);
128 kill(status->pid, SIGTERM); 139 kill(status->pid, SIGTERM);
129 switch (status->protocol) { 140 switch (status->protocol) {
130 case PROTOCOL_I3BAR: { 141 case PROTOCOL_I3BAR: {