[CRIU] [PATCH] criu: don't use a glibc cached pid

Cyrill Gorcunov gorcunov at gmail.com
Tue Mar 28 02:05:49 PDT 2017


On Tue, Mar 28, 2017 at 04:35:30AM +0300, Andrei Vagin wrote:
> From: Andrei Vagin <avagin at virtuozzo.com>
> 
> In glibc 2.24, getpid() returns a parent PID, if a child was created
> with the CLONE_VM flag.
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=17214
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=857909
> 
> The glibc git contains the next patch, which removes cached pid too:
>  commit c579f48edba88380635ab98cb612030e3ed8691e
>  Author: Adhemerval Zanella <adhemerval.zanella at linaro.org>
>  Date:   Mon Oct 10 15:08:39 2016 -0300
> 
>     Remove cached PID/TID in clone
> 
> Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
> ---
>  criu/util.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/criu/util.c b/criu/util.c
> index 38387ff..0671853 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -1393,3 +1393,12 @@ out_close:
>  out_munmap:
>  	return ret;
>  }
> +
> +/*
> + * In glibc 2.24, getpid() returns a parent PID, if a child was
> + * created with the CLONE_VM flag.
> + */
> +int getpid()
> +{
> +       return syscall(__NR_getpid);
> +}

Won't it conflict with existing libc function? Or getpid is
declared as __weak()? I would rather prefer gettid() and use
it instead

pid_t gettid(void)
{
	return syscall(__NR_gettid);
}


More information about the CRIU mailing list