shared: introduce os_fd_clear_cloexec()
This function will be used between fork() and exec() to remove the close-on-exec flag. The first user will be compositor/xwayland.c. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
0260b8a0b5
commit
99b2b958f9
|
@ -40,6 +40,21 @@
|
||||||
|
|
||||||
#define READONLY_SEALS (F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE)
|
#define READONLY_SEALS (F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE)
|
||||||
|
|
||||||
|
int
|
||||||
|
os_fd_clear_cloexec(int fd)
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
flags = fcntl(fd, F_GETFD);
|
||||||
|
if (flags == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (fcntl(fd, F_SETFD, flags & ~(int)FD_CLOEXEC) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_fd_set_cloexec(int fd)
|
os_fd_set_cloexec(int fd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
os_fd_clear_cloexec(int fd);
|
||||||
|
|
||||||
int
|
int
|
||||||
os_fd_set_cloexec(int fd);
|
os_fd_set_cloexec(int fd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue