From: Christian Brauner Date: Sat, 16 Dec 2017 00:23:17 +0000 (+0100) Subject: namespace: add lxc_raw_getpid() X-Git-Tag: lxc-2.0.10~454 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d74dfbb09b3fbb5a9b5f4a6ddc24589dfe81936f;p=thirdparty%2Flxc.git namespace: add lxc_raw_getpid() 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 --- diff --git a/src/lxc/namespace.h b/src/lxc/namespace.h index 5064b27c0..3779ee767 100644 --- a/src/lxc/namespace.h +++ b/src/lxc/namespace.h @@ -23,8 +23,9 @@ #ifndef __LXC_NAMESPACE_H #define __LXC_NAMESPACE_H -#include #include +#include +#include #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