|
Line 0
Link Here
|
|
|
1 |
.\" |
| 2 |
.\" $FreeBSD: src/share/man/man3/pthread_atfork.3,v 1.0 2004/06/21 15:59:00 xx Exp $ |
| 3 |
.\" |
| 4 |
.Dd June 21, 2004 |
| 5 |
.Dt PTHREAD_ATFORK 3 |
| 6 |
.Os |
| 7 |
.Sh NAME |
| 8 |
.Nm pthread_atfork |
| 9 |
.Nd register fork handlers |
| 10 |
.Sh LIBRARY |
| 11 |
.Lb libpthread |
| 12 |
.Sh SYNOPSIS |
| 13 |
.In pthread.h |
| 14 |
.Ft int |
| 15 |
.Fo pthread_atfork |
| 16 |
.Fa "void \*[lp]*prepare\*[rp]\*[lp]void\*[rp]" |
| 17 |
.Fa "void \*[lp]*parent\*[rp]\*[lp]void\*[rp]" |
| 18 |
.Fa "void \*[lp]*child\*[rp]\*[lp]void\*[rp]" |
| 19 |
.Fc |
| 20 |
.Sh DESCRIPTION |
| 21 |
The |
| 22 |
.Fn pthread_atfork |
| 23 |
function declares fork handlers to be called before and after |
| 24 |
.Xr fork 2 , |
| 25 |
in the context of the thread that called |
| 26 |
.Xr fork 2 . |
| 27 |
The |
| 28 |
.Fa prepare |
| 29 |
fork handler will be called before |
| 30 |
.Xr fork 2 |
| 31 |
processing commences. |
| 32 |
The |
| 33 |
.Fa parent |
| 34 |
fork handle will be called after |
| 35 |
.Xr fork 2 |
| 36 |
processing completes in the parent process. |
| 37 |
The |
| 38 |
.Fa child |
| 39 |
fork handler will be called after |
| 40 |
.Xr fork 2 |
| 41 |
processing completes in the child process. |
| 42 |
If no handling is desired at one or more of these three points, the |
| 43 |
corresponding fork handler address(es) may be set to NULL. |
| 44 |
.Pp |
| 45 |
The order of calls to |
| 46 |
.Fn pthread_atfork |
| 47 |
is significant. |
| 48 |
The |
| 49 |
.Fa parent |
| 50 |
and |
| 51 |
.Fa child |
| 52 |
fork handlers will be called in the order in which they were |
| 53 |
established by calls to |
| 54 |
.Fn pthread_atfork . |
| 55 |
The |
| 56 |
.Fa prepare |
| 57 |
fork handlers will be called in the opposite order. |
| 58 |
.Sh RETURN VALUES |
| 59 |
Upon successful completion, |
| 60 |
.Fn pthread_atfork |
| 61 |
returns a value of zero; otherwise, an error number is returned |
| 62 |
to indicate the error. |
| 63 |
.Sh ERRORS |
| 64 |
The |
| 65 |
.Fn pthread_atfork |
| 66 |
function will fail if: |
| 67 |
.Bl -tag -width Er |
| 68 |
.It Bq Er ENOMEM |
| 69 |
Insufficient table space exists to record the fork handler addresses. |
| 70 |
.Sh SEE ALSO |
| 71 |
.Xr fork 2 , |
| 72 |
.Xr pthread 3 |
| 73 |
.Sh STANDARDS |
| 74 |
The |
| 75 |
.Fn pthread_atfork |
| 76 |
function is expected to conform to |
| 77 |
.St -p1003.1 . |