]> git.ipfire.org Git - thirdparty/glibc.git/blame - include/register-atfork.h
test-container: Fix "unused code" warnings on HURD
[thirdparty/glibc.git] / include / register-atfork.h
CommitLineData
2b47727c 1/* Internal pthread_atfork definitions.
581c785b 2 Copyright (C) 2021-2022 Free Software Foundation, Inc.
33574c17
ST
3 This file is part of the GNU C Library.
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
5a82c748 17 <https://www.gnu.org/licenses/>. */
33574c17 18
2b47727c
AZ
19#ifndef _REGISTER_ATFORK_H
20#define _REGISTER_ATFORK_H
21
22/* Elements of the fork handler lists. */
23struct fork_handler
24{
25 void (*prepare_handler) (void);
26 void (*parent_handler) (void);
27 void (*child_handler) (void);
28 void *dso_handle;
29};
30
33574c17
ST
31/* Function to call to unregister fork handlers. */
32extern void __unregister_atfork (void *dso_handle) attribute_hidden;
33#define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
34
2b47727c
AZ
35enum __run_fork_handler_type
36{
37 atfork_run_prepare,
38 atfork_run_child,
39 atfork_run_parent
40};
41
42/* Run the atfork handlers and lock/unlock the internal lock depending
43 of the WHO argument:
44
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.
51
52 Perform locking only if DO_LOCKING. */
53extern void __run_fork_handlers (enum __run_fork_handler_type who,
54 _Bool do_locking) attribute_hidden;
33574c17
ST
55
56/* C library side function to register new fork handlers. */
57extern int __register_atfork (void (*__prepare) (void),
58 void (*__parent) (void),
59 void (*__child) (void),
60 void *dso_handle);
61libc_hidden_proto (__register_atfork)
2b47727c
AZ
62
63#endif