Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (n - p) pthread_atfork(2)
EXAMPLES
If your library uses a mutex my_mutex, you might provide pthread_atfork() handler routines
coded as follows:
void my_prepare(void)
{
pthread_mutex_lock(&my_mutex);
}
void my_parent(void)
{
pthread_mutex_unlock(&my_mutex);
}
void my_child(void)
{
pthread_mutex_unlock(&my_mutex);
/* Reinitialize state that doesnt apply...like heap owned */
/* by other threads */
}
{
.
.
.
pthread_atfork(my_prepare, my_parent, my_child);
.
.
fork();
}
NOTES
Do not call pthread_atfork() from within a fork-handler routine. Doing so could cause a
deadlock.
RETURN VALUES
If an error condition occurs, this function returns an integer value indicating the type of error.
Possible return values are:
0 Successful completion.
[ENOMEM] Insufcient table space exists to record the fork-handler routinesaddresses.
RELATED INFORMATION
Functions: pthread_create(2).
STANDARDS CONFORMANCE
This function is an extension to the XPG4 Version 2 specication. Interfaces documented on this
reference page conform to the following industry standards:
IEEE Std 1003.1c-1995, POSIX System Application Program Interface
The use of the header le spthread.h is an HP exception to the POSIX standard.
527186-003 Hewlett-Packard Company 517