waitpid.c 908 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <stdlib.h>
  9. #include <sys/types.h>
  10. #include <sys/wait.h>
  11. #include <sys/resource.h>
  12. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  13. #include "sysdep-cancel.h"
  14. #else
  15. #define SINGLE_THREAD_P 1
  16. #endif
  17. libc_hidden_proto(wait4)
  18. extern __typeof(waitpid) __libc_waitpid;
  19. __pid_t __libc_waitpid(__pid_t pid, int *wait_stat, int options)
  20. {
  21. if (SINGLE_THREAD_P)
  22. return wait4(pid, wait_stat, options, NULL);
  23. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  24. int oldtype = LIBC_CANCEL_ASYNC ();
  25. int result = wait4(pid, wait_stat, options, NULL);
  26. LIBC_CANCEL_RESET (oldtype);
  27. return result;
  28. #endif
  29. }
  30. libc_hidden_proto(waitpid)
  31. weak_alias(__libc_waitpid,waitpid)
  32. libc_hidden_weak(waitpid)