]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: add lxc_cloexec()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 18 Oct 2017 17:48:29 +0000 (19:48 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 8 Nov 2017 23:18:56 +0000 (00:18 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/utils.h

index 2638438f1c3eeca999fce70cdca671d20e6062a6..4aa21cdd457bbcf8bdccfdd9dc7e900816599d67 100644 (file)
@@ -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))