blob: 9b529eb21767730cfeb00a9e5d2f8178d40c33c4 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
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
13extern __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
20pid_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
44weak_alias(__libc_wait,wait)