nis: Fix leak on realloc failure in nis_getnames [BZ #28150]
[glibc.git] / include / register-atfork.h
blobfadde14700947ac6bf6597a4feb2e94691b0953b
1 /* Internal pthread_atfork definitions.
2 Copyright (C) 2021 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. */
23 struct fork_handler
25 void (*prepare_handler) (void);
26 void (*parent_handler) (void);
27 void (*child_handler) (void);
28 void *dso_handle;
31 /* Function to call to unregister fork handlers. */
32 extern void __unregister_atfork (void *dso_handle) attribute_hidden;
33 #define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
35 enum __run_fork_handler_type
37 atfork_run_prepare,
38 atfork_run_child,
39 atfork_run_parent
42 /* Run the atfork handlers and lock/unlock the internal lock depending
43 of the WHO argument:
45 - atfork_run_prepare: run all the PREPARE_HANDLER in reverse order of
46 insertion and locks the internal lock.
47 - atfork_run_child: run all the CHILD_HANDLER and unlocks the internal
48 lock.
49 - atfork_run_parent: run all the PARENT_HANDLER and unlocks the internal
50 lock.
52 Perform locking only if DO_LOCKING. */
53 extern void __run_fork_handlers (enum __run_fork_handler_type who,
54 _Bool do_locking) 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),
60 void *dso_handle);
61 libc_hidden_proto (__register_atfork)
63 #endif