From bb196a1aa09560c46b7cda62d53bed9d3781c958 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sat, 16 Dec 2017 01:23:17 +0100 Subject: [PATCH] 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 --- src/lxc/namespace.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lxc/namespace.h b/src/lxc/namespace.h index 84453d9f0..1d98ce226 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" @@ -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 -- 2.47.2