diff options
| author | Brian Ashworth <bosrsf04@gmail.com> | 2019-04-14 00:27:47 -0400 | 
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2019-04-14 12:41:59 +0300 | 
| commit | 6961bf2e4ce2c116e41a8db158691f6c993707ce (patch) | |
| tree | a381146599a5f19e565006cafeb23edc04247d2b /common | |
| parent | 8c69da11bbe70caa2f5db1665e9d60387604c5e4 (diff) | |
| download | sway-6961bf2e4ce2c116e41a8db158691f6c993707ce.tar.xz | |
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.c | 19 | 
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; +} | 
