]>
Commit | Line | Data |
---|---|---|
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 | |
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 | |
224c7076 A |
22 | .Fn fork , |
23 | while the | |
3d9156a7 A |
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 | .Fa prepare | |
31 | handlers are called in reverse order of their registration, while | |
32 | .Fa parent | |
33 | and | |
34 | .Fa child | |
35 | handlers are called in the order in which they were registered. Any of the handlers may | |
36 | be NULL. | |
37 | .Pp | |
38 | Remember: only async-cancel-safe functions are allowed on the child side of | |
39 | .Fn fork | |
40 | .Sh RETURN VALUES | |
41 | If successful, the | |
42 | .Fn pthread_atfork | |
43 | function will return zero; otherwise an error number will be returned to | |
44 | indicate the error. | |
45 | .Sh ERRORS | |
46 | .Fn pthread_atfork | |
47 | will fail if: | |
48 | .Bl -tag -width Er | |
49 | .It Bq Er ENOMEM | |
50 | The 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 | |
56 | conforms to | |
57 | .St -p1003.1-96 . |