From b499121f1fd0729d84a64458038a01f7009d707c Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 18 Oct 2017 19:48:29 +0200 Subject: [PATCH] utils: add lxc_cloexec() Signed-off-by: Christian Brauner --- src/lxc/utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lxc/utils.h b/src/lxc/utils.h index 2005aa61e..881a09d5d 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -241,6 +241,11 @@ static inline int memfd_create(const char *name, unsigned int flags) { extern int memfd_create(const char *name, unsigned int flags); #endif +static inline int lxc_set_cloexec(int fd) +{ + return fcntl(fd, F_SETFD, FD_CLOEXEC); +} + /* Struct to carry child pid from lxc_popen() to lxc_pclose(). * Not an opaque struct to allow direct access to the underlying FILE * * (i.e., struct lxc_popen_FILE *file; fgets(buf, sizeof(buf), file->f))