1 /* Internal pthread_atfork definitions.
2 Copyright (C) 2021-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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 <https://www.gnu.org/licenses/>. */
19 #ifndef _REGISTER_ATFORK_H
20 #define _REGISTER_ATFORK_H
22 /* Elements of the fork handler lists. */
25 void (*prepare_handler
) (void);
26 void (*parent_handler
) (void);
27 void (*child_handler
) (void);
32 /* Function to call to unregister fork handlers. */
33 extern void __unregister_atfork (void *dso_handle
) attribute_hidden
;
34 #define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
36 enum __run_fork_handler_type
43 /* Run the atfork prepare handlers in the reverse order of registration and
44 return the ID of the last registered handler. If DO_LOCKING is true, the
45 internal lock is held locked upon return. */
46 extern uint64_t __run_prefork_handlers (_Bool do_locking
) attribute_hidden
;
48 /* Given a handler type (parent or child), run all the atfork handlers in
49 the order of registration up to and including the handler with id equal
50 to LASTRUN. If DO_LOCKING is true, the internal lock is unlocked prior
52 extern void __run_postfork_handlers (enum __run_fork_handler_type who
,
54 uint64_t lastrun
) attribute_hidden
;
56 /* C library side function to register new fork handlers. */
57 extern int __register_atfork (void (*__prepare
) (void),
58 void (*__parent
) (void),
59 void (*__child
) (void),
61 libc_hidden_proto (__register_atfork
)