Rename symbol set_cloexec to sway_set_cloexec, remove duplicates.

set_cloexec is defined by both sway and wlroots (and who-knows-else),
so rename the sway one for supporting static linkage. We also remove
the duplicate version of this in client/.

Fixes: https://github.com/swaywm/sway/issues/4677
master
Sheena Artrip 5 years ago committed by Drew DeVault
parent cf95de9cae
commit 7efb5d4673

@ -11,19 +11,7 @@
#include <wayland-client.h> #include <wayland-client.h>
#include "config.h" #include "config.h"
#include "pool-buffer.h" #include "pool-buffer.h"
#include "util.h"
static bool set_cloexec(int fd) {
long flags = fcntl(fd, F_GETFD);
if (flags == -1) {
return false;
}
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
return false;
}
return true;
}
static int create_pool_file(size_t size, char **name) { static int create_pool_file(size_t size, char **name) {
static const char template[] = "sway-client-XXXXXX"; static const char template[] = "sway-client-XXXXXX";
@ -46,7 +34,7 @@ static int create_pool_file(size_t size, char **name) {
return -1; return -1;
} }
if (!set_cloexec(fd)) { if (!sway_set_cloexec(fd, true)) {
close(fd); close(fd);
return -1; return -1;
} }

@ -77,7 +77,7 @@ const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel)
return NULL; return NULL;
} }
bool set_cloexec(int fd, bool cloexec) { bool sway_set_cloexec(int fd, bool cloexec) {
int flags = fcntl(fd, F_GETFD); int flags = fcntl(fd, F_GETFD);
if (flags == -1) { if (flags == -1) {
sway_log_errno(SWAY_ERROR, "fcntl failed"); sway_log_errno(SWAY_ERROR, "fcntl failed");

@ -32,6 +32,6 @@ float parse_float(const char *value);
const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel); const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel);
bool set_cloexec(int fd, bool cloexec); bool sway_set_cloexec(int fd, bool cloexec);
#endif #endif

@ -194,7 +194,7 @@ static void invoke_swaybar(struct bar_config *bar) {
sway_log_errno(SWAY_ERROR, "socketpair failed"); sway_log_errno(SWAY_ERROR, "socketpair failed");
return; return;
} }
if (!set_cloexec(sockets[0], true) || !set_cloexec(sockets[1], true)) { if (!sway_set_cloexec(sockets[0], true) || !sway_set_cloexec(sockets[1], true)) {
return; return;
} }
@ -222,7 +222,7 @@ static void invoke_swaybar(struct bar_config *bar) {
sway_log_errno(SWAY_ERROR, "fork failed"); sway_log_errno(SWAY_ERROR, "fork failed");
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} else if (pid == 0) { } else if (pid == 0) {
if (!set_cloexec(sockets[1], false)) { if (!sway_set_cloexec(sockets[1], false)) {
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

@ -505,7 +505,7 @@ static bool _spawn_swaybg(char **command) {
sway_log_errno(SWAY_ERROR, "socketpair failed"); sway_log_errno(SWAY_ERROR, "socketpair failed");
return false; return false;
} }
if (!set_cloexec(sockets[0], true) || !set_cloexec(sockets[1], true)) { if (!sway_set_cloexec(sockets[0], true) || !sway_set_cloexec(sockets[1], true)) {
return false; return false;
} }
@ -529,7 +529,7 @@ static bool _spawn_swaybg(char **command) {
sway_log_errno(SWAY_ERROR, "fork failed"); sway_log_errno(SWAY_ERROR, "fork failed");
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} else if (pid == 0) { } else if (pid == 0) {
if (!set_cloexec(sockets[1], false)) { if (!sway_set_cloexec(sockets[1], false)) {
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

@ -36,7 +36,7 @@ bool swaynag_spawn(const char *swaynag_command,
sway_log(SWAY_ERROR, "Failed to create pipe for swaynag"); sway_log(SWAY_ERROR, "Failed to create pipe for swaynag");
return false; return false;
} }
if (!set_cloexec(swaynag->fd[1], true)) { if (!sway_set_cloexec(swaynag->fd[1], true)) {
goto failed; goto failed;
} }
} }
@ -46,7 +46,7 @@ bool swaynag_spawn(const char *swaynag_command,
sway_log_errno(SWAY_ERROR, "socketpair failed"); sway_log_errno(SWAY_ERROR, "socketpair failed");
goto failed; goto failed;
} }
if (!set_cloexec(sockets[0], true) || !set_cloexec(sockets[1], true)) { if (!sway_set_cloexec(sockets[0], true) || !sway_set_cloexec(sockets[1], true)) {
goto failed; goto failed;
} }
@ -69,7 +69,7 @@ bool swaynag_spawn(const char *swaynag_command,
sway_log_errno(SWAY_ERROR, "fork failed"); sway_log_errno(SWAY_ERROR, "fork failed");
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} else if (pid == 0) { } else if (pid == 0) {
if (!set_cloexec(sockets[1], false)) { if (!sway_set_cloexec(sockets[1], false)) {
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

Loading…
Cancel
Save