diff options
-rw-r--r-- | client/pool-buffer.c | 16 | ||||
-rw-r--r-- | common/util.c | 2 | ||||
-rw-r--r-- | include/util.h | 2 | ||||
-rw-r--r-- | sway/config/bar.c | 4 | ||||
-rw-r--r-- | sway/config/output.c | 4 | ||||
-rw-r--r-- | sway/swaynag.c | 6 |
6 files changed, 11 insertions, 23 deletions
diff --git a/client/pool-buffer.c b/client/pool-buffer.c index 836c6b13..fd500c49 100644 --- a/client/pool-buffer.c +++ b/client/pool-buffer.c | |||
@@ -11,19 +11,7 @@ | |||
11 | #include <wayland-client.h> | 11 | #include <wayland-client.h> |
12 | #include "config.h" | 12 | #include "config.h" |
13 | #include "pool-buffer.h" | 13 | #include "pool-buffer.h" |
14 | 14 | #include "util.h" | |
15 | static bool set_cloexec(int fd) { | ||
16 | long flags = fcntl(fd, F_GETFD); | ||
17 | if (flags == -1) { | ||
18 | return false; | ||
19 | } | ||
20 | |||
21 | if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) { | ||
22 | return false; | ||
23 | } | ||
24 | |||
25 | return true; | ||
26 | } | ||
27 | 15 | ||
28 | static int create_pool_file(size_t size, char **name) { | 16 | static int create_pool_file(size_t size, char **name) { |
29 | static const char template[] = "sway-client-XXXXXX"; | 17 | static const char template[] = "sway-client-XXXXXX"; |
@@ -46,7 +34,7 @@ static int create_pool_file(size_t size, char **name) { | |||
46 | return -1; | 34 | return -1; |
47 | } | 35 | } |
48 | 36 | ||
49 | if (!set_cloexec(fd)) { | 37 | if (!sway_set_cloexec(fd, true)) { |
50 | close(fd); | 38 | close(fd); |
51 | return -1; | 39 | return -1; |
52 | } | 40 | } |
diff --git a/common/util.c b/common/util.c index 3a807edb..c0324b2f 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -77,7 +77,7 @@ const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel) | |||
77 | return NULL; | 77 | return NULL; |
78 | } | 78 | } |
79 | 79 | ||
80 | bool set_cloexec(int fd, bool cloexec) { | 80 | bool sway_set_cloexec(int fd, bool cloexec) { |
81 | int flags = fcntl(fd, F_GETFD); | 81 | int flags = fcntl(fd, F_GETFD); |
82 | if (flags == -1) { | 82 | if (flags == -1) { |
83 | sway_log_errno(SWAY_ERROR, "fcntl failed"); | 83 | sway_log_errno(SWAY_ERROR, "fcntl failed"); |
diff --git a/include/util.h b/include/util.h index 6d9454e0..3cba49f0 100644 --- a/include/util.h +++ b/include/util.h | |||
@@ -32,6 +32,6 @@ float parse_float(const char *value); | |||
32 | 32 | ||
33 | const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel); | 33 | const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel); |
34 | 34 | ||
35 | bool set_cloexec(int fd, bool cloexec); | 35 | bool sway_set_cloexec(int fd, bool cloexec); |
36 | 36 | ||
37 | #endif | 37 | #endif |
diff --git a/sway/config/bar.c b/sway/config/bar.c index f90fcdc0..1c7c13b2 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c | |||
@@ -194,7 +194,7 @@ static void invoke_swaybar(struct bar_config *bar) { | |||
194 | sway_log_errno(SWAY_ERROR, "socketpair failed"); | 194 | sway_log_errno(SWAY_ERROR, "socketpair failed"); |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | if (!set_cloexec(sockets[0], true) || !set_cloexec(sockets[1], true)) { | 197 | if (!sway_set_cloexec(sockets[0], true) || !sway_set_cloexec(sockets[1], true)) { |
198 | return; | 198 | return; |
199 | } | 199 | } |
200 | 200 | ||
@@ -222,7 +222,7 @@ static void invoke_swaybar(struct bar_config *bar) { | |||
222 | sway_log_errno(SWAY_ERROR, "fork failed"); | 222 | sway_log_errno(SWAY_ERROR, "fork failed"); |
223 | _exit(EXIT_FAILURE); | 223 | _exit(EXIT_FAILURE); |
224 | } else if (pid == 0) { | 224 | } else if (pid == 0) { |
225 | if (!set_cloexec(sockets[1], false)) { | 225 | if (!sway_set_cloexec(sockets[1], false)) { |
226 | _exit(EXIT_FAILURE); | 226 | _exit(EXIT_FAILURE); |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/sway/config/output.c b/sway/config/output.c index 50bf1155..42deec67 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -505,7 +505,7 @@ static bool _spawn_swaybg(char **command) { | |||
505 | sway_log_errno(SWAY_ERROR, "socketpair failed"); | 505 | sway_log_errno(SWAY_ERROR, "socketpair failed"); |
506 | return false; | 506 | return false; |
507 | } | 507 | } |
508 | if (!set_cloexec(sockets[0], true) || !set_cloexec(sockets[1], true)) { | 508 | if (!sway_set_cloexec(sockets[0], true) || !sway_set_cloexec(sockets[1], true)) { |
509 | return false; | 509 | return false; |
510 | } | 510 | } |
511 | 511 | ||
@@ -529,7 +529,7 @@ static bool _spawn_swaybg(char **command) { | |||
529 | sway_log_errno(SWAY_ERROR, "fork failed"); | 529 | sway_log_errno(SWAY_ERROR, "fork failed"); |
530 | _exit(EXIT_FAILURE); | 530 | _exit(EXIT_FAILURE); |
531 | } else if (pid == 0) { | 531 | } else if (pid == 0) { |
532 | if (!set_cloexec(sockets[1], false)) { | 532 | if (!sway_set_cloexec(sockets[1], false)) { |
533 | _exit(EXIT_FAILURE); | 533 | _exit(EXIT_FAILURE); |
534 | } | 534 | } |
535 | 535 | ||
diff --git a/sway/swaynag.c b/sway/swaynag.c index 0fca6c71..db5a919a 100644 --- a/sway/swaynag.c +++ b/sway/swaynag.c | |||
@@ -36,7 +36,7 @@ bool swaynag_spawn(const char *swaynag_command, | |||
36 | sway_log(SWAY_ERROR, "Failed to create pipe for swaynag"); | 36 | sway_log(SWAY_ERROR, "Failed to create pipe for swaynag"); |
37 | return false; | 37 | return false; |
38 | } | 38 | } |
39 | if (!set_cloexec(swaynag->fd[1], true)) { | 39 | if (!sway_set_cloexec(swaynag->fd[1], true)) { |
40 | goto failed; | 40 | goto failed; |
41 | } | 41 | } |
42 | } | 42 | } |
@@ -46,7 +46,7 @@ bool swaynag_spawn(const char *swaynag_command, | |||
46 | sway_log_errno(SWAY_ERROR, "socketpair failed"); | 46 | sway_log_errno(SWAY_ERROR, "socketpair failed"); |
47 | goto failed; | 47 | goto failed; |
48 | } | 48 | } |
49 | if (!set_cloexec(sockets[0], true) || !set_cloexec(sockets[1], true)) { | 49 | if (!sway_set_cloexec(sockets[0], true) || !sway_set_cloexec(sockets[1], true)) { |
50 | goto failed; | 50 | goto failed; |
51 | } | 51 | } |
52 | 52 | ||
@@ -69,7 +69,7 @@ bool swaynag_spawn(const char *swaynag_command, | |||
69 | sway_log_errno(SWAY_ERROR, "fork failed"); | 69 | sway_log_errno(SWAY_ERROR, "fork failed"); |
70 | _exit(EXIT_FAILURE); | 70 | _exit(EXIT_FAILURE); |
71 | } else if (pid == 0) { | 71 | } else if (pid == 0) { |
72 | if (!set_cloexec(sockets[1], false)) { | 72 | if (!sway_set_cloexec(sockets[1], false)) { |
73 | _exit(EXIT_FAILURE); | 73 | _exit(EXIT_FAILURE); |
74 | } | 74 | } |
75 | 75 | ||