]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
namespace: add lxc_raw_getpid()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 16 Dec 2017 00:23:17 +0000 (01:23 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 1 Jan 2018 23:50:53 +0000 (00:50 +0100)
Because of older glibc's pid cache (up to 2.25) whenever clone() is called the
child must must retrieve it's own pid via lxc_raw_getpid().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/namespace.h

index 5064b27c0a667d9fe66ee47323f1a88ef1453876..3779ee7674126fa1dabb673467fd0c12fc6e82e6 100644 (file)
@@ -23,8 +23,9 @@
 #ifndef __LXC_NAMESPACE_H
 #define __LXC_NAMESPACE_H
 
-#include <sys/syscall.h>
 #include <sched.h>
+#include <unistd.h>
+#include <sys/syscall.h>
 
 #include "config.h"
 
@@ -117,4 +118,13 @@ extern pid_t lxc_raw_clone(unsigned long flags);
 extern int lxc_namespace_2_cloneflag(char *namespace);
 extern int lxc_fill_namespace_flags(char *flaglist, int *flags);
 
+/**
+ * Because of older glibc's pid cache (up to 2.25) whenever clone() is called
+ * the child must must retrieve it's own pid via lxc_raw_getpid().
+ */
+static inline pid_t lxc_raw_getpid(void)
+{
+       return (pid_t) syscall(SYS_getpid);
+}
+
 #endif