aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSheena Artrip <sheena.artrip@gmail.com>2019-10-28 22:54:16 -0700
committerDrew DeVault <sir@cmpwn.com>2019-11-01 12:41:08 -0400
commit7efb5d467368ea9168cebc2473bc3c6942e031bb (patch)
tree2d707d7d6c85453fdc187ecd5e8c8cda34493300
parentcf95de9cae0561a58d6435802411dcee63ef2f5f (diff)
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
-rw-r--r--client/pool-buffer.c16
-rw-r--r--common/util.c2
-rw-r--r--include/util.h2
-rw-r--r--sway/config/bar.c4
-rw-r--r--sway/config/output.c4
-rw-r--r--sway/swaynag.c6
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 @@
#include <wayland-client.h>
#include "config.h"
#include "pool-buffer.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;
-}
+#include "util.h"
static int create_pool_file(size_t size, char **name) {
static const char template[] = "sway-client-XXXXXX";
@@ -46,7 +34,7 @@ static int create_pool_file(size_t size, char **name) {
return -1;
}
- if (!set_cloexec(fd)) {
+ if (!sway_set_cloexec(fd, true)) {
close(fd);
return -1;
}
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)
return NULL;
}
-bool set_cloexec(int fd, bool cloexec) {
+bool sway_set_cloexec(int fd, bool cloexec) {
int flags = fcntl(fd, F_GETFD);
if (flags == -1) {
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);
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
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) {
sway_log_errno(SWAY_ERROR, "socketpair failed");
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;
}
@@ -222,7 +222,7 @@ static void invoke_swaybar(struct bar_config *bar) {
sway_log_errno(SWAY_ERROR, "fork failed");
_exit(EXIT_FAILURE);
} else if (pid == 0) {
- if (!set_cloexec(sockets[1], false)) {
+ if (!sway_set_cloexec(sockets[1], false)) {
_exit(EXIT_FAILURE);
}
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) {
sway_log_errno(SWAY_ERROR, "socketpair failed");
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;
}
@@ -529,7 +529,7 @@ static bool _spawn_swaybg(char **command) {
sway_log_errno(SWAY_ERROR, "fork failed");
_exit(EXIT_FAILURE);
} else if (pid == 0) {
- if (!set_cloexec(sockets[1], false)) {
+ if (!sway_set_cloexec(sockets[1], false)) {
_exit(EXIT_FAILURE);
}
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,
sway_log(SWAY_ERROR, "Failed to create pipe for swaynag");
return false;
}
- if (!set_cloexec(swaynag->fd[1], true)) {
+ if (!sway_set_cloexec(swaynag->fd[1], true)) {
goto failed;
}
}
@@ -46,7 +46,7 @@ bool swaynag_spawn(const char *swaynag_command,
sway_log_errno(SWAY_ERROR, "socketpair 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;
}
@@ -69,7 +69,7 @@ bool swaynag_spawn(const char *swaynag_command,
sway_log_errno(SWAY_ERROR, "fork failed");
_exit(EXIT_FAILURE);
} else if (pid == 0) {
- if (!set_cloexec(sockets[1], false)) {
+ if (!sway_set_cloexec(sockets[1], false)) {
_exit(EXIT_FAILURE);
}