fork.h 2.2 KB

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