]>
Commit | Line | Data |
---|---|---|
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 | |
15 | The | |
16 | .Fn pthread_atfork | |
17 | function is used to register functions to be called before and after | |
18 | .Fn fork . | |
19 | The | |
20 | .Fa prepare | |
21 | handler is called before | |
22 | .Fn fork , | |
23 | while the | |
24 | .Fa parent | |
25 | and | |
26 | .Fa child | |
27 | handlers are called after | |
28 | .Fn fork | |
29 | in the parent and child process respectively. | |
30 | The | |
31 | .Fa prepare | |
32 | handlers are called in reverse order of their registration, while | |
33 | .Fa parent | |
34 | and | |
35 | .Fa child | |
36 | handlers are called in the order in which they were registered. | |
37 | Any of the handlers may be NULL. | |
38 | .Pp | |
39 | .Em Important : | |
40 | only async-signal-safe functions are allowed on the child side of | |
41 | .Fn fork . | |
42 | See | |
43 | .Xr sigaction 2 | |
44 | for details. | |
45 | .Sh RETURN VALUES | |
46 | If successful, the | |
47 | .Fn pthread_atfork | |
48 | function will return zero; otherwise an error number will be returned to | |
49 | indicate the error. | |
50 | .Sh ERRORS | |
51 | .Fn pthread_atfork | |
52 | will fail if: | |
53 | .Bl -tag -width Er | |
54 | .It Bq Er ENOMEM | |
55 | The 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 | |
61 | conforms to | |
62 | .St -p1003.1-96 . |