From: Christian Brauner Date: Wed, 18 Oct 2017 17:48:29 +0000 (+0200) Subject: utils: add lxc_cloexec() X-Git-Tag: lxc-2.0.10~620 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=785c692d7b780eca67eb458ab7094c0a1bcca0ee;p=thirdparty%2Flxc.git utils: add lxc_cloexec() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/utils.h b/src/lxc/utils.h index 606538a2a..a17e26785 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))