Skip to content

Commit

Permalink
tests: add waitid test
Browse files Browse the repository at this point in the history
  • Loading branch information
no92 committed Feb 21, 2024
1 parent 2a80078 commit 4c7ed4c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sysdeps/linux/generic/sysdeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,13 @@ int sys_semctl(int semid, int semnum, int cmd, void *semun, int *out) {
return 0;
}

int sys_waitid(idtype_t idtype, id_t id, siginfo_t *info, int options) {
auto ret = do_syscall(SYS_waitid, idtype, id, info, options, 0);
if(int e = sc_error(ret); e)
return e;
return sc_int_result<int>(ret);
}

#endif // __MLIBC_POSIX_OPTION

#if __MLIBC_LINUX_OPTION
Expand Down
1 change: 1 addition & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ all_test_cases = [
'posix/posix-timer',
'posix/strdupa',
'posix/mkstemp',
'posix/waitid',
'glibc/getopt',
'glibc/ffsl-ffsll',
'glibc/error_message_count',
Expand Down
20 changes: 20 additions & 0 deletions tests/posix/waitid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <assert.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>

siginfo_t si;

int main() {
int pid = fork();

if(!pid)
exit(69);

int ret = waitid(P_ALL, 0, &si, WEXITED);
assert(ret == 0);
assert(si.si_pid == pid);
assert(si.si_signo == SIGCHLD);
assert(si.si_code == CLD_EXITED);
}

0 comments on commit 4c7ed4c

Please sign in to comment.