PTHREAD_ATFORK(3) | Library Functions Manual | PTHREAD_ATFORK(3) |
pthread_atfork
—
register handlers to be called before and after
fork
()
#include
<pthread.h>
int
pthread_atfork
(void
(*prepare)(void), void (*parent)(void),
void (*child)(void));
The
pthread_atfork
()
function declares fork handlers to be called before and after
fork(2), in the context of the thread
that called fork(2).
The handlers registered with
pthread_atfork
()
are called at the moments in time described below:
If no handling is desired at one or more of these three points, a null pointer may be passed as the corresponding fork handler.
Important:
only async-signal-safe functions are allowed on the child side of
fork
().
See sigaction(2) for details.
If successful, the pthread_atfork
()
function will return zero. Otherwise an error number will be returned to
indicate the error.
The pthread_atfork
() function will fail
if:
ENOMEM
]The pthread_atfork
() conforms to
ISO/IEC 9945-1:1996 (“POSIX.1”).
June 21, 2004 | macOS 15.2 |