OpenBSD manual page server

Manual Page Search Parameters

PTHREAD_ATFORK(3) Library Functions Manual PTHREAD_ATFORK(3)

pthread_atforkspecify handler functions to call when the process forks

#include <pthread.h>

int
pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));

The () function declares fork handlers to be called before and after (), in the context of the thread that called fork(). The prepare fork handler will be called before fork() processing commences. The parent fork handler will be called after fork() processing completes in the parent process. The child fork handler will be called after fork() processing completes in the child process. If no handling is desired at one or more of these three points, the corresponding fork handler address(es) may be set to NULL.

The order of calls to () is significant. The parent and child fork handlers will be called in the order in which they were established by calls to pthread_atfork(). The prepare fork handlers will be called in the opposite order.

Upon successful completion, pthread_atfork() will return a value of zero. Otherwise, an error number will be returned to indicate the error.

pthread_atfork() will fail if:

[]
Insufficient table space exists to record the fork handler addresses. None of the handler lists are modified.

fork(2), atexit(3)

pthread_atfork() conforms to IEEE Std 1003.1-2004 (“POSIX.1”).

June 5, 2013 OpenBSD-5.6