]> 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>
Sat, 21 Oct 2017 14:30:08 +0000 (16:30 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/utils.h

index 2005aa61e54142132dddc2442f6665689e507dba..881a09d5d39eea0891c7953b5cb894a8d82431f4 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))