[Previous] [Contents] [Next]

pthread_atfork()

Register fork handlers

Synopsis:

#include <process.h>

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

Library:

libc

Description:

The pthread_atfork() function registers fork handler functions to be called before and after a fork(), in the context of the thread that called fork(). The prepare fork handler is called before the fork, the parent fork handler is called after the fork in the parent process, and the child fork handler is called after the fork in the child process. One or more of the arguments may be set to NULL to indicate no handler.

Multiple prepare, parent and child fork handlers may be registered by repeated calls to pthread_atfork(). In this case the parent and child handlers are called in the order they were registered, and the prepare handlers are called in the reverse order.

Returns:

EOK
Success.
ENOMEM
Insufficient memory to record fork handlers.

Classification:

POSIX 1003.1 (Threads)

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

atexit(), fork()


[Previous] [Contents] [Next]