|
|
HP-UX Reference > Ppthread_atfork(3T)Pthread LibraryHP-UX 11i Version 2: December 2007 Update |
|
NAMEpthread_atfork() — register fork handlers. SYNOPSIS#include <pthread.h> int pthread_atfork( void (*prepare)(void), void (*parent)(void), void (*child)(void) ); PARAMETERS
DESCRIPTIONThe pthread_atfork() function allows an application to install fork handlers. These fork handlers will be called before and after a fork() operation. These handlers will be called in the context of the thread calling fork(). Similar to the atexit() handlers, the application does not need to do anything special for these fork handlers to be called. They will be invoked by the system when a fork() operation occurs. The prepare() function is called before the fork() operation in the parent process. The parent() function is called after the fork() operation in the parent process. The child() function is called after the fork() operation in the child process. If a fork handler is not needed in one or more of these three places, the appropriate fork handler parameter may be set to NULL. A process may install multiple fork handling functions. The parent() and child() fork handlers will be called in the order in which they were installed (i.e., First-In, First-Out). The prepare() fork handlers will be called in the opposite order (i.e., Last-In, First-Out). RETURN VALUEUpon successful completion, pthread_atfork() returns zero. Otherwise, an error number is returned to indicate the error (the errno variable is not set). |
|