Re: Is fork() hook ever possible?

From: Attilio Rao <attilio_at_freebsd.org>
Date: Tue, 16 Sep 2008 16:53:54 +0200
2008/9/16, Andrey Chernov <ache_at_nagual.pp.ru>:
> On Tue, Sep 16, 2008 at 03:38:16PM +0100, Bob Bishop wrote:
>  > Hi,
>
> >
>  > On 16 Sep 2008, at 15:03, Andrey Chernov wrote:
>  >
>  > > I need some sort of fork() hook to detect that pid is changed to re-
>  > > stir
>  > > ar4random() after that (in the child), simple flag variable with
>  > > child's pid is needed.
>  > >
>  > > Currently OpenBSD does almost that checking getpid() every time
>  > > arc4random() called, but it is very slow way to use getpid() syscall
>  > > repeatedly, about 12-15 times slower than just arc4random() without
>  > > getpid().
>  > >
>  > > Any ideas?
>  >
>
> > How about something hacky using mmap()/minherit()?
>
>  Could you please provide working low cost example to detect that we are in
>  the child (pid changed or something else)? Calling getpid() as OpenBSD
>  does definitely is very high cost. :(

An idea would be to implement a shared page between process and system
which exports such informations.
I'm sure we have a SoC project (2007) implementing this and perforce
branches for it, I'm just not sure how far it did end.

Thanks,
Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
Received on Tue Sep 16 2008 - 12:54:01 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:35 UTC