xref: /aosp_15_r20/external/llvm-libc/src/sys/wait/linux/wait4.cpp (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- Linux implementation of wait4 -------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "src/__support/common.h"
10 #include "src/__support/libc_assert.h"
11 
12 #include "src/__support/macros/config.h"
13 #include "src/sys/wait/wait4.h"
14 #include "src/sys/wait/wait4Impl.h"
15 
16 namespace LIBC_NAMESPACE_DECL {
17 
18 LLVM_LIBC_FUNCTION(pid_t, wait4,
19                    (pid_t pid, int *wait_status, int options,
20                     struct rusage *usage)) {
21   auto result = internal::wait4impl(pid, wait_status, options, usage);
22   if (!result.has_value()) {
23     libc_errno = result.error();
24     return -1;
25   }
26   return result.value();
27 }
28 
29 } // namespace LIBC_NAMESPACE_DECL
30