PTHREAD_ATFORK (3) | C library functions | Unix Manual Pages | :man▋
pthread_atfork - register fork handlers
.In pthread.h int
.Fo pthread_atfork "void lp]*preparerp]lp]voidrp]" "void lp]*parentrp]lp]voidrp]" "void lp]*childrp]lp]voidrp]"
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:
| prepare || Before fork(2) processing commences in the parent process. If more than one prepare handler is registered they will be called in the opposite order they were registered. |
| parent || After fork(2) completes in the parent process. If more than one parent handler is registered they will be called in the same order they were registered. |
| child || After fork(2) processing completes in the child process. If more than one child handler is registered they will be called in the same order they were registered. |
If no handling is desired at one or more of these three points, a null pointer may be passed as the corresponding fork handler.
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:
| || Insufficient table space exists to record the fork handler addresses. |
Share this page