atfork(3thr)atfork(3thr)Nameatfork - Arranges for fork cleanup handling
void pthread_create (user_state, pre_fork, parent_fork, child_fork)
Pointer to the user state that is passed to each routine.
Routine to be called before performing the fork.
Routine to be called after the fork, in the parent.
Routine to be called after the fork, in the child.
This routine allows you to register three routines to be executed at
different times relative to a fork. The different times and/or places
Just prior to the fork in the parent process
Just after the fork in the parent process
Just after the fork in the created (child) process
Use these routines to clean up just prior to fork(), to set up after
fork(), and to perform locking relative to fork(). You are allowed to
provide one argument to be used in conjunction with all the routines.
This parameter must be: user_state.
Note that if your library's pre-fork action routine consists of locking
all of your library's mutexes, then your library must be coded such
that your code never holds a mutex during a call to another library
which would lock one of that library's mutexes. Otherwise, you risk
entering a deadlock when your pre-fork action routine is called, if the
the other library has an analogous pre-fork action routine that has
already been called for this fork.
This routine returns 0 if successful. Otherwise, it returns -1 if there
is insufficient table space to record the handler addresses.