1 /* Copyright (C) 2002 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18 
19 #include <list.h>
20 #include <bits/libc-lock.h>
21 
22 struct fork_block
23 {
24   /* Lock to protect handling of fork handlers.  */
25   __libc_lock_define (, lock);
26 
27   /* Lists of registered fork handlers.  */
28   list_t prepare_list;
29   list_t parent_list;
30   list_t child_list;
31 };
32 
33 extern struct fork_block __fork_block attribute_hidden;
34 
35 /* Elements of the fork handler lists.  */
36 struct fork_handler
37 {
38   list_t list;
39   void (*handler) (void);
40   void *dso_handle;
41 };
42 
43 
44 /* Function to call to unregister fork handlers.  */
45 extern void __unregister_atfork (void *dso_handle) attribute_hidden;
46 #define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
47 
48 
49 /* C library side function to register new fork handlers.  */
50 extern int __register_atfork (void (*__prepare) (void),
51 			      void (*__parent) (void),
52 			      void (*__child) (void),
53 			      void *dso_handle);
54 
55 #ifndef ARCH_FORK
56 # define ARCH_FORK() __libc_fork()
57 #endif
58