This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Q: How do I tell libc to refresh it's pid cache.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]