Line 0
Link Here
|
|
|
1 |
.\" |
2 |
.\" "THE BEER-WARE LICENSE" (Revision 42m): |
3 |
.\" <mikko@dynas.se> wrote this file. As long as you retain this notice you |
4 |
.\" can do whatever you want with this stuff. If we meet some day, and you think |
5 |
.\" this stuff is worth it, you can buy me a beer in return. Mikko Työläjärvi |
6 |
.\" |
7 |
.\" $FreeBSD$ |
8 |
.\" |
9 |
.Dd March 16, 2000 |
10 |
.Dt PTHREAD_ATFORK 3 |
11 |
.Os BSD 4 |
12 |
.Sh NAME |
13 |
.Nm pthread_atfork |
14 |
.Nd register fork handlers |
15 |
.Sh SYNOPSIS |
16 |
.Fd #include <pthread.h> |
17 |
.Ft int |
18 |
.Fn pthread_atfork "void (*prepare)(void)" "void (*parent)(void)" "void (*child)(void)" |
19 |
.Sh DESCRIPTION |
20 |
The |
21 |
.Fn pthread_atfork |
22 |
function registers fork handlers to be called before and after |
23 |
.Fn fork . |
24 |
Handlers are run in the context of the thread that calls |
25 |
.Fn fork . |
26 |
.Pp |
27 |
The |
28 |
.Fa prepare |
29 |
handlers are invoked before fork processing. The |
30 |
.Fa parent |
31 |
and |
32 |
.Fa child |
33 |
handlers are invoked after fork processing, in the parent and child |
34 |
processes respectively. |
35 |
Handlers will be called in the parent process even when the |
36 |
.Fn fork |
37 |
operation fails. |
38 |
.Pp |
39 |
Any number of handlers can be registered by |
40 |
.Fn pthread_atfork . |
41 |
Function pointers that are NULL will be ignored. |
42 |
The |
43 |
.Fa Parent |
44 |
and |
45 |
.Fa child |
46 |
handlers are called in the order that they were registered. The |
47 |
.Fn prepare |
48 |
handlers are called in the reverse order. |
49 |
.Pp |
50 |
.Sh RETURN VALUES |
51 |
If successful, the |
52 |
.Fn pthread_atfork |
53 |
function will return zero. |
54 |
Otherwise an error number will be returned to |
55 |
indicate the error. |
56 |
.Sh ERRORS |
57 |
.Fn pthread_atfork |
58 |
will fail if: |
59 |
.Bl -tag -width Er |
60 |
.It Bq Er ENOMEM |
61 |
The process cannot allocate enough memory to register another set of |
62 |
handlers. |
63 |
.El |
64 |
.Pp |
65 |
.Sh SEE ALSO |
66 |
.Xr fork 2 , |
67 |
.Xr atexit 3 |
68 |
.Sh STANDARDS |
69 |
.Fn pthread_atfork |
70 |
conforms to ISO/IEC 9945-1 ANSI/IEEE |
71 |
.Pq Dq Tn POSIX |
72 |
.\" XXX: Dunno -- someone will have to check the exact details: |
73 |
Std 1003.1 Second Edition 1996-07-12. |