fork.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (C) 2002, 2003, 2006, 2007 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 <lowlevellock.h>
  16. /* The fork generation counter, defined in libpthread. */
  17. extern unsigned long int __fork_generation attribute_hidden;
  18. /* Pointer to the fork generation counter in the thread library. */
  19. extern unsigned long int *__fork_generation_pointer attribute_hidden;
  20. /* Lock to protect allocation and deallocation of fork handlers. */
  21. extern int __fork_lock attribute_hidden;
  22. /* Elements of the fork handler lists. */
  23. struct fork_handler
  24. {
  25. struct fork_handler *next;
  26. void (*prepare_handler) (void);
  27. void (*parent_handler) (void);
  28. void (*child_handler) (void);
  29. void *dso_handle;
  30. unsigned int refcntr;
  31. int need_signal;
  32. };
  33. /* The single linked list of all currently registered for handlers. */
  34. extern struct fork_handler *__fork_handlers attribute_hidden;
  35. /* Function to call to unregister fork handlers. */
  36. extern void __unregister_atfork (void *dso_handle) attribute_hidden;
  37. #define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
  38. /* C library side function to register new fork handlers. */
  39. extern int __register_atfork (void (*__prepare) (void),
  40. void (*__parent) (void),
  41. void (*__child) (void),
  42. void *dso_handle);
  43. libc_hidden_proto (__register_atfork)
  44. /* Add a new element to the fork list. */
  45. extern void __linkin_atfork (struct fork_handler *newp) attribute_hidden;