]> 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>
Thu, 9 Nov 2017 00:03:56 +0000 (01:03 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/utils.h

index 606538a2aa183f0a59b3cbcf159eb6c4b799b162..a17e267858d863cb354ec9fd5af65ce9a6bc7807 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))