]> git.saurik.com Git - apple/libpthread.git/blame - man/pthread_atfork.3
libpthread-138.10.4.tar.gz
[apple/libpthread.git] / man / pthread_atfork.3
CommitLineData
f1a1da6c
A
1.\" Copyright (c) 2004 Apple Computer, Inc.
2.\"
3.Dd August 12, 2004
4.Dt PTHREAD_ATFORK 3
5.Os
6.Sh NAME
7.Nm pthread_atfork
8.Nd register handlers to be called before and after
9.Fn fork
10.Sh SYNOPSIS
11.Fd #include <pthread.h>
12.Ft int
13.Fn pthread_atfork "void (*prepare)(void)" "void (*parent)(void)" "void (*child)(void)"
14.Sh DESCRIPTION
15The
16.Fn pthread_atfork
17function is used to register functions to be called before and after
18.Fn fork .
19The
20.Fa prepare
21handler is called before
22.Fn fork ,
23while the
24.Fa parent
25and
26.Fa child
27handlers are called after
28.Fn fork
29in the parent and child process respectively.
30The
31.Fa prepare
32handlers are called in reverse order of their registration, while
33.Fa parent
34and
35.Fa child
36handlers are called in the order in which they were registered.
37Any of the handlers may be NULL.
38.Pp
39.Em Important :
40only async-signal-safe functions are allowed on the child side of
41.Fn fork .
42See
43.Xr sigaction 2
44for details.
45.Sh RETURN VALUES
46If successful, the
47.Fn pthread_atfork
48function will return zero; otherwise an error number will be returned to
49indicate the error.
50.Sh ERRORS
51.Fn pthread_atfork
52will fail if:
53.Bl -tag -width Er
54.It Bq Er ENOMEM
55The system lacked the necessary resources to add another handler to the list.
56.El
57.Sh SEE ALSO
58.Xr fork 2
59.Sh STANDARDS
60.Fn pthread_atfork
61conforms to
62.St -p1003.1-96 .