1995105deSSiva Chandra Reddy //===-- Linux implementation of waitpid -----------------------------------===// 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/wait4Impl.h" 14c9783d2bSMikhail R. Gadelha #include "src/sys/wait/waitpid.h" 15995105deSSiva Chandra Reddy 16*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 17995105deSSiva Chandra Reddy 18995105deSSiva Chandra Reddy LLVM_LIBC_FUNCTION(pid_t, waitpid, (pid_t pid, int *wait_status, int options)) { 19c9783d2bSMikhail R. Gadelha auto result = internal::wait4impl(pid, wait_status, options, 0); 20c9783d2bSMikhail R. Gadelha if (!result.has_value()) { 21c9783d2bSMikhail R. Gadelha libc_errno = result.error(); 22995105deSSiva Chandra Reddy return -1; 23995105deSSiva Chandra Reddy } 24c9783d2bSMikhail R. Gadelha return result.value(); 25995105deSSiva Chandra Reddy } 26995105deSSiva Chandra Reddy 27*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 28