]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
bindings: provide lxcfs_clone() as wrapper around lxcfs_raw_clone()
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 6 Jul 2020 09:05:14 +0000 (11:05 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 6 Jul 2020 09:05:14 +0000 (11:05 +0200)
Closes: #420.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/bindings.h

index 4ab4f721aa8d06f85199baf4cb5abf5729dc0b42..e26090296e22a87be3c4eceda935caf359e7ce5a 100644 (file)
@@ -104,6 +104,20 @@ static inline int install_signal_handler(int signo,
        return sigaction(signo, &action, NULL);
 }
 
-extern pid_t lxcfs_clone(int (*fn)(void *), void *arg, int flags);
+extern pid_t lxcfs_raw_clone(unsigned long flags, int *pidfd);
+
+static inline pid_t lxcfs_clone(int (*fn)(void *), void *arg, int flags)
+{
+       pid_t pid;
+
+       pid = lxcfs_raw_clone(flags, NULL);
+       if (pid < 0)
+               return -1;
+
+       if (pid == 0)
+               _exit(fn(arg));
+
+       return pid;
+}
 
 #endif /* __LXCFS_BINDINGS_H */