[libc-commits] [libc] [libc] Implement waitid in sys/wait (PR #227815)
Aman Maurya via libc-commits
libc-commits at lists.llvm.org
Wed Sep 30 22:50:16 PDT 2026
https://github.com/amanmaurya92 updated https://github.com/llvm/llvm-project/pull/227815
>From afc38e6a596a9a222cb099e8a39a6e122080a0f0 Mon Sep 17 00:00:00 2001
From: amanmaurya92 <amanmaurya9209 at gmail.com>
Date: Wed, 30 Sep 2026 23:38:47 +0530
Subject: [PATCH] [libc][sys] Implement waitid in sys/wait
Assisted by Antigravity and reviewed by Aman Maurya
---
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/riscv/entrypoints.txt | 1 +
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/hdr/types/CMakeLists.txt | 9 ++++
libc/hdr/types/idtype_t.h | 27 ++++++++++++
libc/include/CMakeLists.txt | 2 +
.../llvm-libc-macros/linux/sys-wait-macros.h | 19 ++++++++
libc/include/llvm-libc-types/CMakeLists.txt | 1 +
libc/include/llvm-libc-types/idtype_t.h | 40 +++++++++++++++++
libc/include/sys/wait.yaml | 11 +++++
.../linux/syscall_wrappers/CMakeLists.txt | 16 +++++++
.../OSUtil/linux/syscall_wrappers/waitid.h | 42 ++++++++++++++++++
libc/src/sys/wait/CMakeLists.txt | 7 +++
libc/src/sys/wait/linux/CMakeLists.txt | 16 +++++++
libc/src/sys/wait/linux/waitid.cpp | 36 +++++++++++++++
libc/src/sys/wait/waitid.h | 28 ++++++++++++
.../integration/src/unistd/CMakeLists.txt | 1 +
.../test/integration/src/unistd/fork_test.cpp | 35 +++++++++++++++
libc/test/src/sys/wait/CMakeLists.txt | 14 ++++++
libc/test/src/sys/wait/waitid_test.cpp | 44 +++++++++++++++++++
20 files changed, 351 insertions(+)
create mode 100644 libc/hdr/types/idtype_t.h
create mode 100644 libc/include/llvm-libc-types/idtype_t.h
create mode 100644 libc/src/__support/OSUtil/linux/syscall_wrappers/waitid.h
create mode 100644 libc/src/sys/wait/linux/waitid.cpp
create mode 100644 libc/src/sys/wait/waitid.h
create mode 100644 libc/test/src/sys/wait/waitid_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 9bb9407a7624b..8b1c6fc30076d 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -398,6 +398,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# sys/wait.h entrypoints
libc.src.sys.wait.wait
libc.src.sys.wait.wait4
+ libc.src.sys.wait.waitid
libc.src.sys.wait.waitpid
# sys/xattr.h entrypoints
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 475c6bbd5fbac..b8b8b9000dfd3 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -433,6 +433,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# sys/wait.h entrypoints
libc.src.sys.wait.wait
libc.src.sys.wait.wait4
+ libc.src.sys.wait.waitid
libc.src.sys.wait.waitpid
# sys/prctl.h entrypoints
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 1007ba4775cd7..7ebdc0659f1cb 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -437,6 +437,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# sys/wait.h entrypoints
libc.src.sys.wait.wait
libc.src.sys.wait.wait4
+ libc.src.sys.wait.waitid
libc.src.sys.wait.waitpid
# sys/xattr.h entrypoints
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index 505c2d9fa6579..d11f28236dd8f 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -1415,3 +1415,12 @@ add_proxy_header_library(
FULL_BUILD_DEPENDS
libc.include.llvm-libc-types.id_t
)
+
+add_proxy_header_library(
+ idtype_t
+ HDRS
+ idtype_t.h
+ FULL_BUILD_DEPENDS
+ libc.include.llvm-libc-types.idtype_t
+)
+
diff --git a/libc/hdr/types/idtype_t.h b/libc/hdr/types/idtype_t.h
new file mode 100644
index 0000000000000..35f9165c28b0c
--- /dev/null
+++ b/libc/hdr/types/idtype_t.h
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Proxy for idtype_t.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_HDR_TYPES_IDTYPE_T_H
+#define LLVM_LIBC_HDR_TYPES_IDTYPE_T_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/idtype_t.h"
+
+#else // Overlay mode
+
+#include <sys/wait.h>
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_IDTYPE_T_H
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 2fe1f92afc1d1..f2ba791ce57a3 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -1097,6 +1097,8 @@ add_header_macro(
.llvm-libc-types.pid_t
.llvm-libc-types.struct_rusage
.llvm-libc-types.siginfo_t
+ .llvm-libc-types.id_t
+ .llvm-libc-types.idtype_t
)
add_header_macro(
diff --git a/libc/include/llvm-libc-macros/linux/sys-wait-macros.h b/libc/include/llvm-libc-macros/linux/sys-wait-macros.h
index d01cfa71ba390..5eaa94f5d7018 100644
--- a/libc/include/llvm-libc-macros/linux/sys-wait-macros.h
+++ b/libc/include/llvm-libc-macros/linux/sys-wait-macros.h
@@ -11,6 +11,25 @@
#include <linux/wait.h>
+// <linux/wait.h> defines P_ALL, P_PID, P_PGID, P_PIDFD as numeric macros.
+// Undefine them so they do not collide with the idtype_t enum specified by
+// POSIX.
+#ifdef P_ALL
+#undef P_ALL
+#endif
+
+#ifdef P_PID
+#undef P_PID
+#endif
+
+#ifdef P_PGID
+#undef P_PGID
+#endif
+
+#ifdef P_PIDFD
+#undef P_PIDFD
+#endif
+
#define WCOREDUMP(status) ((status) & WCOREFLAG)
#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
#define WIFCONTINUED(status) ((status) == 0xffff)
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index ea710ef48857c..00a62c7d995a0 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -78,6 +78,7 @@ add_header(caddr_t HDR caddr_t.h)
add_header(dev_t HDR dev_t.h)
add_header(div_t HDR div_t.h)
add_header(id_t HDR id_t.h)
+add_header(idtype_t HDR idtype_t.h)
add_header(ino64_t HDR ino64_t.h)
add_header(u_int HDR u_int.h)
add_header(u_int16_t HDR u_int16_t.h)
diff --git a/libc/include/llvm-libc-types/idtype_t.h b/libc/include/llvm-libc-types/idtype_t.h
new file mode 100644
index 0000000000000..11aab766a0636
--- /dev/null
+++ b/libc/include/llvm-libc-types/idtype_t.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of idtype_t type.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_IDTYPE_T_H
+#define LLVM_LIBC_TYPES_IDTYPE_T_H
+
+#ifdef P_ALL
+#undef P_ALL
+#endif
+
+#ifdef P_PID
+#undef P_PID
+#endif
+
+#ifdef P_PGID
+#undef P_PGID
+#endif
+
+#ifdef P_PIDFD
+#undef P_PIDFD
+#endif
+
+typedef enum {
+ P_ALL,
+ P_PID,
+ P_PGID,
+ P_PIDFD,
+} idtype_t;
+
+#endif // LLVM_LIBC_TYPES_IDTYPE_T_H
diff --git a/libc/include/sys/wait.yaml b/libc/include/sys/wait.yaml
index c5928cc1502a8..bf296381a337b 100644
--- a/libc/include/sys/wait.yaml
+++ b/libc/include/sys/wait.yaml
@@ -8,6 +8,8 @@ types:
- type_name: siginfo_t
- type_name: struct_rusage
- type_name: pid_t
+ - type_name: id_t
+ - type_name: idtype_t
enums: []
objects: []
functions:
@@ -27,6 +29,15 @@ functions:
- type: int *
- type: int
- type: struct rusage *
+ - name: waitid
+ standards:
+ - posix
+ return_type: int
+ arguments:
+ - type: idtype_t
+ - type: id_t
+ - type: siginfo_t *
+ - type: int
- name: waitpid
standards:
- posix
diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/CMakeLists.txt b/libc/src/__support/OSUtil/linux/syscall_wrappers/CMakeLists.txt
index 2a24b6b28cab0..c4613ae71418f 100644
--- a/libc/src/__support/OSUtil/linux/syscall_wrappers/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/CMakeLists.txt
@@ -1350,6 +1350,22 @@ add_header_library(
libc.include.sys_syscall
)
+add_header_library(
+ waitid
+ HDRS
+ waitid.h
+ DEPENDS
+ libc.hdr.types.id_t
+ libc.hdr.types.idtype_t
+ libc.hdr.types.siginfo_t
+ libc.hdr.types.struct_rusage
+ libc.src.__support.OSUtil.osutil
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.include.sys_syscall
+)
+
add_header_library(
execve
HDRS
diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/waitid.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/waitid.h
new file mode 100644
index 0000000000000..9d279be736726
--- /dev/null
+++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/waitid.h
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Syscall wrapper for waitid.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_WRAPPERS_WAITID_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_WRAPPERS_WAITID_H
+
+#include "hdr/types/id_t.h"
+#include "hdr/types/idtype_t.h"
+#include "hdr/types/siginfo_t.h"
+#include "hdr/types/struct_rusage.h"
+#include "src/__support/OSUtil/linux/syscall.h" // For syscall_checked
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers
+
+namespace LIBC_NAMESPACE_DECL {
+namespace linux_syscalls {
+
+LIBC_INLINE ErrorOr<int> waitid(idtype_t idtype, id_t id, siginfo_t *infop,
+ int options, struct rusage *rusage = nullptr) {
+#ifdef SYS_waitid
+ return syscall_checked<int>(SYS_waitid, idtype, id, infop, options, rusage);
+#else
+#error "waitid syscall not available."
+#endif
+}
+
+} // namespace linux_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_WRAPPERS_WAITID_H
diff --git a/libc/src/sys/wait/CMakeLists.txt b/libc/src/sys/wait/CMakeLists.txt
index eb572b0618e33..9dce3e5c2422f 100644
--- a/libc/src/sys/wait/CMakeLists.txt
+++ b/libc/src/sys/wait/CMakeLists.txt
@@ -16,6 +16,13 @@ add_entrypoint_object(
.${LIBC_TARGET_OS}.wait4
)
+add_entrypoint_object(
+ waitid
+ ALIAS
+ DEPENDS
+ .${LIBC_TARGET_OS}.waitid
+)
+
add_entrypoint_object(
waitpid
ALIAS
diff --git a/libc/src/sys/wait/linux/CMakeLists.txt b/libc/src/sys/wait/linux/CMakeLists.txt
index 90a98b8c6f437..1799bf4b17ebb 100644
--- a/libc/src/sys/wait/linux/CMakeLists.txt
+++ b/libc/src/sys/wait/linux/CMakeLists.txt
@@ -24,6 +24,22 @@ add_entrypoint_object(
libc.src.errno.errno
)
+add_entrypoint_object(
+ waitid
+ SRCS
+ waitid.cpp
+ HDRS
+ ../waitid.h
+ DEPENDS
+ libc.hdr.types.id_t
+ libc.hdr.types.idtype_t
+ libc.hdr.types.siginfo_t
+ libc.src.__support.OSUtil.linux.syscall_wrappers.waitid
+ libc.src.__support.common
+ libc.src.__support.macros.config
+ libc.src.errno.errno
+)
+
add_entrypoint_object(
waitpid
SRCS
diff --git a/libc/src/sys/wait/linux/waitid.cpp b/libc/src/sys/wait/linux/waitid.cpp
new file mode 100644
index 0000000000000..b04cfb1dfbd16
--- /dev/null
+++ b/libc/src/sys/wait/linux/waitid.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Linux implementation of waitid.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/sys/wait/waitid.h"
+
+#include "hdr/types/id_t.h"
+#include "hdr/types/idtype_t.h"
+#include "hdr/types/siginfo_t.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/waitid.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, waitid,
+ (idtype_t idtype, id_t id, siginfo_t *infop, int options)) {
+ auto result = linux_syscalls::waitid(idtype, id, infop, options, nullptr);
+ if (!result.has_value()) {
+ libc_errno = result.error();
+ return -1;
+ }
+ return 0;
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/sys/wait/waitid.h b/libc/src/sys/wait/waitid.h
new file mode 100644
index 0000000000000..3225b59c521d1
--- /dev/null
+++ b/libc/src/sys/wait/waitid.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation header for waitid.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SYS_WAIT_WAITID_H
+#define LLVM_LIBC_SRC_SYS_WAIT_WAITID_H
+
+#include "hdr/types/id_t.h"
+#include "hdr/types/idtype_t.h"
+#include "hdr/types/siginfo_t.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_SYS_WAIT_WAITID_H
diff --git a/libc/test/integration/src/unistd/CMakeLists.txt b/libc/test/integration/src/unistd/CMakeLists.txt
index 6fe8f5126a05b..069385a532543 100644
--- a/libc/test/integration/src/unistd/CMakeLists.txt
+++ b/libc/test/integration/src/unistd/CMakeLists.txt
@@ -29,6 +29,7 @@ add_integration_test(
libc.src.signal.raise
libc.src.sys.wait.wait
libc.src.sys.wait.wait4
+ libc.src.sys.wait.waitid
libc.src.sys.wait.waitpid
libc.src.unistd.fork
libc.src.unistd.gettid
diff --git a/libc/test/integration/src/unistd/fork_test.cpp b/libc/test/integration/src/unistd/fork_test.cpp
index 7eeefa4477806..6936805ecb23a 100644
--- a/libc/test/integration/src/unistd/fork_test.cpp
+++ b/libc/test/integration/src/unistd/fork_test.cpp
@@ -12,6 +12,7 @@
#include "src/stdlib/exit.h"
#include "src/sys/wait/wait.h"
#include "src/sys/wait/wait4.h"
+#include "src/sys/wait/waitid.h"
#include "src/sys/wait/waitpid.h"
#include "src/unistd/fork.h"
#include "src/unistd/gettid.h"
@@ -55,6 +56,22 @@ void fork_and_wait4_normal_exit() {
ASSERT_TRUE(WIFEXITED(status));
}
+void fork_and_waitid_normal_exit() {
+ pid_t pid = LIBC_NAMESPACE::fork();
+ if (pid == 0)
+ return; // Just end without any thing special.
+ ASSERT_TRUE(pid > 0);
+ siginfo_t info;
+ info.si_pid = 0;
+ info.si_status = 0;
+ int ret =
+ LIBC_NAMESPACE::waitid(P_PID, static_cast<id_t>(pid), &info, WEXITED);
+ ASSERT_EQ(ret, 0);
+ ASSERT_EQ(info.si_pid, pid);
+ ASSERT_EQ(info.si_code, CLD_EXITED);
+ ASSERT_EQ(info.si_status, 0);
+}
+
void fork_and_waitpid_normal_exit() {
pid_t pid = LIBC_NAMESPACE::fork();
if (pid == 0)
@@ -96,6 +113,22 @@ void fork_and_wait4_signal_exit() {
ASSERT_TRUE(WTERMSIG(status) == SIGUSR1);
}
+void fork_and_waitid_signal_exit() {
+ pid_t pid = LIBC_NAMESPACE::fork();
+ if (pid == 0)
+ LIBC_NAMESPACE::raise(SIGUSR1);
+ ASSERT_TRUE(pid > 0);
+ siginfo_t info;
+ info.si_pid = 0;
+ info.si_status = 0;
+ int ret =
+ LIBC_NAMESPACE::waitid(P_PID, static_cast<id_t>(pid), &info, WEXITED);
+ ASSERT_EQ(ret, 0);
+ ASSERT_EQ(info.si_pid, pid);
+ ASSERT_EQ(info.si_code, CLD_KILLED);
+ ASSERT_EQ(info.si_status, SIGUSR1);
+}
+
void fork_and_waitpid_signal_exit() {
pid_t pid = LIBC_NAMESPACE::fork();
if (pid == 0)
@@ -164,9 +197,11 @@ TEST_MAIN([[maybe_unused]] int argc, [[maybe_unused]] char **argv,
gettid_test();
fork_and_wait_normal_exit();
fork_and_wait4_normal_exit();
+ fork_and_waitid_normal_exit();
fork_and_waitpid_normal_exit();
fork_and_wait_signal_exit();
fork_and_wait4_signal_exit();
+ fork_and_waitid_signal_exit();
fork_and_waitpid_signal_exit();
fork_with_atfork_callbacks();
return 0;
diff --git a/libc/test/src/sys/wait/CMakeLists.txt b/libc/test/src/sys/wait/CMakeLists.txt
index 839fc8eac7190..8ed17fb7ec7ac 100644
--- a/libc/test/src/sys/wait/CMakeLists.txt
+++ b/libc/test/src/sys/wait/CMakeLists.txt
@@ -27,3 +27,17 @@ add_libc_test(
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
+
+add_libc_test(
+ waitid_test
+ SUITE
+ libc_sys_wait_unittests
+ SRCS
+ waitid_test.cpp
+ DEPENDS
+ libc.include.sys_wait
+ libc.src.errno.errno
+ libc.src.sys.wait.waitid
+ libc.test.UnitTest.ErrnoCheckingTest
+ libc.test.UnitTest.ErrnoSetterMatcher
+)
diff --git a/libc/test/src/sys/wait/waitid_test.cpp b/libc/test/src/sys/wait/waitid_test.cpp
new file mode 100644
index 0000000000000..caddc02f578c5
--- /dev/null
+++ b/libc/test/src/sys/wait/waitid_test.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Unittests for waitid.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/sys/wait/waitid.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include <sys/wait.h>
+
+using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+using LlvmLibcWaitidTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
+
+// The test here is a simple test for error handling and WNOHANG functionality.
+// For a more involved test, look at fork_test.
+
+TEST_F(LlvmLibcWaitidTest, InvalidFlags) {
+ siginfo_t info;
+ // POSIX and Linux require at least one of WEXITED, WSTOPPED, or WCONTINUED.
+ ASSERT_THAT(LIBC_NAMESPACE::waitid(P_ALL, 0, &info, 0), Fails(EINVAL));
+}
+
+TEST_F(LlvmLibcWaitidTest, InvalidIdType) {
+ siginfo_t info;
+ ASSERT_THAT(
+ LIBC_NAMESPACE::waitid(static_cast<idtype_t>(-1), 0, &info, WEXITED),
+ Fails(EINVAL));
+}
+
+TEST_F(LlvmLibcWaitidTest, NoHangNoChild) {
+ siginfo_t info;
+ ASSERT_THAT(LIBC_NAMESPACE::waitid(P_ALL, 0, &info, WEXITED | WNOHANG),
+ Fails(ECHILD));
+}
More information about the libc-commits
mailing list