From 6961bf2e4ce2c116e41a8db158691f6c993707ce Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sun, 14 Apr 2019 00:27:47 -0400 Subject: Spawn swaynag as a wayland client This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done --- common/util.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'common/util.c') 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 +#include #include #include #include @@ -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; +} -- cgit v1.2.3-54-g00ecf