1995105deSSiva Chandra Reddy //===-- Linux implementation of wait4 -------------------------------------===// 2995105deSSiva Chandra Reddy // 3995105deSSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4995105deSSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information. 5995105deSSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6995105deSSiva Chandra Reddy // 7995105deSSiva Chandra Reddy //===----------------------------------------------------------------------===// 8995105deSSiva Chandra Reddy 9995105deSSiva Chandra Reddy #include "src/__support/common.h" 10c9783d2bSMikhail R. Gadelha #include "src/__support/libc_assert.h" 11995105deSSiva Chandra Reddy 12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 13c9783d2bSMikhail R. Gadelha #include "src/sys/wait/wait4.h" 14c9783d2bSMikhail R. Gadelha #include "src/sys/wait/wait4Impl.h" 15995105deSSiva Chandra Reddy 16*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 17995105deSSiva Chandra Reddy 18995105deSSiva Chandra Reddy LLVM_LIBC_FUNCTION(pid_t, wait4, 19995105deSSiva Chandra Reddy (pid_t pid, int *wait_status, int options, 20995105deSSiva Chandra Reddy struct rusage *usage)) { 21c9783d2bSMikhail R. Gadelha auto result = internal::wait4impl(pid, wait_status, options, usage); 22c9783d2bSMikhail R. Gadelha if (!result.has_value()) { 23c9783d2bSMikhail R. Gadelha libc_errno = result.error(); 24995105deSSiva Chandra Reddy return -1; 25995105deSSiva Chandra Reddy } 26c9783d2bSMikhail R. Gadelha return result.value(); 27995105deSSiva Chandra Reddy } 28995105deSSiva Chandra Reddy 29*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 30