This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Q: How do I tell libc to refresh it's pid cache.
- From: ebiederm at xmission dot com (Eric W. Biederman)
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 01 Sep 2006 20:22:09 -0600
- Subject: Re: Q: How do I tell libc to refresh it's pid cache.
- References: <m1mz9me4nv.fsf@ebiederm.dsl.xmission.com> <20060901231222.GA7865@host0.dyn.jankratochvil.net>
Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Hi Eric,
>
> On Wed, 30 Aug 2006 15:25:56 +0200, Eric W. Biederman wrote:
> ...
>> Is there a good way to have glibc refresh it's pid cache besides
>> calling fork an additional time?
>
> Sure it is hack but you can
> according to
> glibc/nptl/sysdeps/unix/sysv/linux/getpid.c
> set
> (%gs:offsetof (struct pthread, pid)) = 0
> by
> PTRACE_POKE*
> where
> %gs base you get remotely by PTRACE_GET_THREAD_AREA
> and you should possibly query `offsetof' from the remote program's debug info,
> internal or external, unaware how to get it if it is stripped.
Well I'm a library call so I don't need the PTRACE_POKE part.
But since I'm not glibc finding it is hard to get a copy of struct
pthread.
I was hoping for a non-hack solution.
The closest I can think of is overriding __getpid@@GLIBC2.0
and actually make it a real syscall.
But what it really looks like is that to implement this cleanly
without the extra fork, I need to make this function part of glibc.
Or add a pid cache invalidate operation.
Eric