]> git.saurik.com Git - apple/libc.git/blame - pthreads/pthread_atfork.3
Libc-825.40.1.tar.gz
[apple/libc.git] / pthreads / pthread_atfork.3
CommitLineData
3d9156a7
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
224c7076
A
22.Fn fork ,
23while the
3d9156a7
A
24.Fa parent
25and
26.Fa child
27handlers are called after
28.Fn fork
29in the parent and child process, respectively.
30.Fa prepare
31handlers are called in reverse order of their registration, while
32.Fa parent
33and
34.Fa child
35handlers are called in the order in which they were registered. Any of the handlers may
36be NULL.
37.Pp
38Remember: only async-cancel-safe functions are allowed on the child side of
39.Fn fork
40.Sh RETURN VALUES
41If successful, the
42.Fn pthread_atfork
43function will return zero; otherwise an error number will be returned to
44indicate the error.
45.Sh ERRORS
46.Fn pthread_atfork
47will fail if:
48.Bl -tag -width Er
49.It Bq Er ENOMEM
50The system lacked the necessary resources to add another handler to the list.
51.El
52.Sh SEE ALSO
53.Xr fork 2
54.Sh STANDARDS
55.Fn pthread_atfork
56conforms to
57.St -p1003.1-96 .