summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2019-04-14 00:27:47 -0400
committerFurkan Sahin <furkan-dev@proton.me>2019-04-14 00:27:47 -0400
commitce9e7e0526affc72f00e9476f26e610d7c8c6339 (patch)
treea381146599a5f19e565006cafeb23edc04247d2b /common
parentd5e2676d9f01789427ac8ec7c5b0320c18c6f7a8 (diff)
Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done
Diffstat (limited to 'common')
-rw-r--r--common/util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c
index c43c5ddf..3a807edb 100644
--- a/common/util.c
+++ b/common/util.c
@@ -1,5 +1,6 @@
#define _POSIX_C_SOURCE 200809L
#include <float.h>
+#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -75,3 +76,21 @@ const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel)
sway_assert(false, "Unknown value for wl_output_subpixel.");
return NULL;
}
+
+bool set_cloexec(int fd, bool cloexec) {
+ int flags = fcntl(fd, F_GETFD);
+ if (flags == -1) {
+ sway_log_errno(SWAY_ERROR, "fcntl failed");
+ return false;
+ }
+ if (cloexec) {
+ flags = flags | FD_CLOEXEC;
+ } else {
+ flags = flags & ~FD_CLOEXEC;
+ }
+ if (fcntl(fd, F_SETFD, flags) == -1) {
+ sway_log_errno(SWAY_ERROR, "fcntl failed");
+ return false;
+ }
+ return true;
+}