.\" Copyright (c) 2004 Apple Computer, Inc. .\" .Dd August 12, 2004 .Dt PTHREAD_ATFORK 3 .Os .Sh NAME .Nm pthread_atfork .Nd register handlers to be called before and after .Fn fork .Sh SYNOPSIS .Fd #include <pthread.h> .Ft int .Fn pthread_atfork "void (*prepare)(void)" "void (*parent)(void)" "void (*child)(void)" .Sh DESCRIPTION The .Fn pthread_atfork function is used to register functions to be called before and after .Fn fork The .Fa prepare handler is called before .Fn fork , while the .Fa parent and .Fa child handlers are called after .Fn fork in the parent and child process, respectively. .Fa prepare handlers are called in reverse order of their registration, while .Fa parent and .Fa child handlers are called in the order in which they were registered. Any of the handlers may be NULL. .Pp Remember: only async-cancel-safe functions are allowed on the child side of .Fn fork .Sh RETURN VALUES If successful, the .Fn pthread_atfork function will return zero; otherwise an error number will be returned to indicate the error. .Sh ERRORS .Fn pthread_atfork will fail if: .Bl -tag -width Er .It Bq Er ENOMEM The system lacked the necessary resources to add another handler to the list. .El .Sh SEE ALSO .Xr fork 2 .Sh STANDARDS .Fn pthread_atfork conforms to .St -p1003.1-96 .