]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man3/pthread_atfork.3
OpenSSL: update to 3.0.11
[FreeBSD/FreeBSD.git] / share / man / man3 / pthread_atfork.3
1 .\" Copyright (c) 2004 Alex Vasylenko <lxv@omut.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" Portions of this text are reprinted and reproduced in electronic form
26 .\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
27 .\" Portable Operating System Interface (POSIX), The Open Group Base
28 .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
29 .\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
30 .\" event of any discrepancy between this version and the original IEEE and
31 .\" The Open Group Standard, the original IEEE and The Open Group Standard is
32 .\" the referee document.  The original Standard can be obtained online at
33 .\"     http://www.opengroup.org/unix/online.html.
34 .\"
35 .Dd June 21, 2004
36 .Dt PTHREAD_ATFORK 3
37 .Os
38 .Sh NAME
39 .Nm pthread_atfork
40 .Nd register fork handlers
41 .Sh LIBRARY
42 .Lb libpthread
43 .Sh SYNOPSIS
44 .In pthread.h
45 .Ft int
46 .Fo pthread_atfork
47 .Fa "void \*[lp]*prepare\*[rp]\*[lp]void\*[rp]"
48 .Fa "void \*[lp]*parent\*[rp]\*[lp]void\*[rp]"
49 .Fa "void \*[lp]*child\*[rp]\*[lp]void\*[rp]"
50 .Fc
51 .Sh DESCRIPTION
52 The
53 .Fn pthread_atfork
54 function declares fork handlers to be called before and after
55 .Xr fork 2 ,
56 in the context of the thread that called
57 .Xr fork 2 .
58 .Pp
59 The handlers registered with
60 .Fn pthread_atfork
61 are called at the moments in time described below:
62 .Bl -tag -width ".Fa prepare"
63 .It Fa prepare
64 Before
65 .Xr fork 2
66 processing commences in the parent process.
67 If more than one
68 .Fa prepare
69 handler is registered they will be called in the opposite order
70 they were registered.
71 .It Fa parent
72 After
73 .Xr fork 2
74 completes in the parent process.
75 If more than one
76 .Fa parent
77 handler is registered they will be called in the same order
78 they were registered.
79 .It Fa child
80 After
81 .Xr fork 2
82 processing completes in the child process.
83 If more than one
84 .Fa child
85 handler is registered they will be called in the same order
86 they were registered.
87 .El
88 .Pp
89 If no handling is desired at one or more of these three points,
90 a null pointer may be passed as the corresponding fork handler.
91 .Sh RETURN VALUES
92 If successful, the
93 .Fn pthread_atfork
94 function will return zero.
95 Otherwise an error number will be returned to indicate the error.
96 .Sh ERRORS
97 The
98 .Fn pthread_atfork
99 function will fail if:
100 .Bl -tag -width Er
101 .It Bq Er ENOMEM
102 Insufficient table space exists to record the fork handler addresses.
103 .El
104 .Sh SEE ALSO
105 .Xr fork 2 ,
106 .Xr pthread 3
107 .Sh STANDARDS
108 The
109 .Fn pthread_atfork
110 function is expected to conform to
111 .St -p1003.1 .
112 .Sh AUTHORS
113 This manpage was written by
114 .An Alex Vasylenko Aq Mt lxv@omut.org .