Is fork() hook ever possible?

Andrey Chernov ache at
Wed Sep 17 09:45:48 UTC 2008

On Wed, Sep 17, 2008 at 09:34:12AM +0000, Poul-Henning Kamp wrote:
> In message <20080917093238.GA59500 at>, Andrey Chernov writes:
> >On Wed, Sep 17, 2008 at 09:24:01AM +0000, Poul-Henning Kamp wrote:
> >> Just have the FreeBSD library calls, call the wrapper function that
> >> does a pid check and be done with it.
> >
> >I understand your idea and it was first idea that comes to me too, but 
> >since API is not ours, it does not work that way.
> Well, in that case, you should leave the "slow" check in place and
> live with it.

Not so doomed. As already discussed in this thread we can ether:

a) Add *fork() hook to clear arc4random's flag which inidicates it is 
stired (to re-stir it on the next call). This slightly increases diffs 
with OpenBSD arc4random code.

b) Speed up getpid() itself by caching its value (adding *fork() and 
getpid() hooks). This produces no diffs with OpenBSD arc4random code. That 
way give more benefits for other program that calls getpid() often to 
check they are in the child, but I don't have examples.


More information about the freebsd-current mailing list