From: Christian Brauner Date: Wed, 18 Oct 2017 17:48:29 +0000 (+0200) Subject: utils: add lxc_cloexec() X-Git-Tag: lxc-3.0.0.beta1~210^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b499121f1fd0729d84a64458038a01f7009d707c;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 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))