]> 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>
Thu, 21 Dec 2017 22:00:22 +0000 (23:00 +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 84453d9f0df5c3c54ea6c921a6d60b640304a8e9..1d98ce226024de627c21c51dc7c9a9d066aaa29a 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"
 
@@ -119,4 +120,13 @@ extern int lxc_namespace_2_cloneflag(const char *namespace);
 extern int lxc_namespace_2_ns_idx(const 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