]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/wait.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / wait.c
1 /*
2  * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
3  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4  *
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7 #include <stdlib.h>
8 #include <syscall.h>
9 #include <sys/types.h>
10 #include <sys/wait.h>
11 #include <sys/resource.h>
12
13 extern __typeof(wait) __libc_wait;
14 /* Wait for a child to die.  When one does, put its status in *STAT_LOC
15  * and return its process ID.  For errors, return (pid_t) -1.  */
16 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
17 #include <errno.h>
18 #include <sysdep-cancel.h>
19
20 pid_t attribute_hidden
21 __libc_wait (__WAIT_STATUS_DEFN stat_loc)
22 {
23   if (SINGLE_THREAD_P)
24     return INLINE_SYSCALL (wait4, 4, WAIT_ANY, stat_loc, 0,
25                            (struct rusage *) NULL);
26
27   int oldtype = LIBC_CANCEL_ASYNC ();
28
29   pid_t result = INLINE_SYSCALL (wait4, 4, WAIT_ANY, stat_loc, 0,
30                                  (struct rusage *) NULL);
31
32   LIBC_CANCEL_RESET (oldtype);
33
34   return result;
35 }
36 #else
37 /* Wait for a child to die.  When one does, put its status in *STAT_LOC
38  * and return its process ID.  For errors, return (pid_t) -1.  */
39 __pid_t __libc_wait (__WAIT_STATUS_DEFN stat_loc)
40 {
41       return wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL);
42 }
43 #endif
44 weak_alias(__libc_wait,wait)