pthread_atfork_unregister_np Subroutine`

Purpose

Unregisters fork handlers.

Library

Threads Library (libpthreads.a).

Syntax

#include <sys/types.h>
#include <unistd.h>
int pthread_atfork_unregister_np (arg, prepare, parent, child, flags)
void *arg;
void (*prepare)();
void (*parent)();
void (*child)();
int flags;

Description

The pthread_atfork_unregister_np subroutine unregisters functions for pre and post fork handling. The fork handlers must be previously registered by using either the pthread_atfork or the pthread_atfork_np subroutine.

The flags parameter determines what handlers are unregistered. It might be any of the following

0
The first POSIX handler that matches will be unregistered.
PTHREAD_ATFORK_ALL
All POSIX duplicate handlers that match and all nonportable handlers that differ only in argument value will be unregistered.
PTHREAD_ATFORK_ARGUMENT
The first nonportable handler that matches will be unregistered.

The preceding flags might be combined by using the bitwise OR operation. , The flag value of PTHREAD_ATFORK_ARGUMENT | PTHREAD_ATFORK_ALL might cause all nonportable duplicate handlers that match to be unregistered.

Note:
  • The pthread.h header file must be the first file included of each source file by using the threads library.
  • The pthread_atfork_unregister_np subroutine is not portable.
  • The handlers that take parameter are nonportable.
  • The handlers that do not take parameters are POSIX compliant and are referred to as POSIX handlers.

Parameters

arg
Points to the parameter to be passed to the fork cleanup handlers. If the handlers do not take a parameter, the value of this pointer must be set to NULL.
prepare
The pre-fork cleanup handler.
parent
The parent post-fork cleanup handler.
child
The child post-fork cleanup handler.
flags
Defines what handlers are to be unregistered.

Return Values

Upon successful completion, the pthread_atfork_unregister_np subroutine returns a value of zero. Otherwise, an error number is returned to indicate the error.

Error Codes

EINVAL
Arguments do not identify a fork handler.