The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

pthread_atfork - register fork handlers

 SYNOPSIS



#include <sys/types.h>
#include <unistd.h>

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

 DESCRIPTION

The pthread_atfork() function declares fork handlers to be called before and after fork(), in the context of the thread that called fork(). The prepare fork handler is called before fork() processing commences. The parent fork handle is called after fork() processing completes in the parent process. The child fork handler is 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 pthread_atfork() is significant. The parent and child fork handlers are called in the order in which they were established by calls to pthread_atfork(). The prepare fork handlers are called in the opposite order.

 RETURN VALUE

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

 ERRORS

The pthread_atfork() function will fail if:
[ENOMEM]
Insufficient table space exists to record the fork handler addresses.

The pthread_atfork() function will not return an error code of [EINTR].

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

atexit(), fork(), <sys/types.h>

DERIVATION

Derived from the POSIX Threads Extension (1003.1c-1995) including PASC 1003.1c-95.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]