fork.h 1.7 KB

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