Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > P

pthread_atfork(3T)

Pthread Library
HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

pthread_atfork() — register fork handlers.

SYNOPSIS

#include <pthread.h>

int pthread_atfork(

void (*prepare)(void), void (*parent)(void), void (*child)(void)

);

PARAMETERS

prepare

This function is called before performing the fork().

parent

This function is called in the parent process after performing the fork().

child

This function is called in the child process after performing the fork().

DESCRIPTION

The 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 VALUE

Upon successful completion, pthread_atfork() returns zero. Otherwise, an error number is returned to indicate the error (the errno variable is not set).

ERRORS

If any of the following occur, the pthread_atfork() function returns the corresponding error number:

[ENOMEM]

There is insufficient table space to install the fork handlers.

AUTHOR

pthread_atfork() was derived from the IEEE POSIX P1003.1c standard.

SEE ALSO

fork(2), atexit(3).

STANDARDS CONFORMANCE

pthread_atfork(): POSIX 1003.1c.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.