[lxc-devel] [lxcfs/master] bindings: provide lxcfs_clone() as wrapper around lxcfs_raw_clone()
brauner on Github
lxc-bot at linuxcontainers.org
Mon Jul 6 09:06:07 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 380 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200706/2ef042b4/attachment.bin>
-------------- next part --------------
From 1bdeec69b9a1c3b890019c09ce4016b665e3bb78 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 6 Jul 2020 11:05:14 +0200
Subject: [PATCH] bindings: provide lxcfs_clone() as wrapper around
lxcfs_raw_clone()
Closes: #420.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/bindings.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/bindings.h b/src/bindings.h
index 4ab4f72..e260902 100644
--- a/src/bindings.h
+++ b/src/bindings.h
@@ -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 */
More information about the lxc-devel
mailing list