Pre-fork and post-fork callback infrastructure ...

Richard Sharpe realrichardsharpe at
Wed May 6 16:10:46 MDT 2015

Hi folks,

I encountered a problem with the Zookeeper work I did a while ago
because the Zookeeper client library is not fork safe. I had to hack a
bunch of code in to reinit the connection to the Zookeeper server in
each child.

I notice that we already have reinit_after_fork and wondered whether
we should have some standard infrastructure for where things need to
be reinitialized after a fork.

The sort of thing I am thinking of is some registration routines that
allows a subsystem to register:

1. A pre-fork callback. This would be called in the parent just before
the fork and passed an opaque pointer to a private data structure.

2. A post-fork callback that would be called in the parent and the
child and passed the response from fork and an opaque pointer.

Richard Sharpe

More information about the samba-technical mailing list