Skip to content

Commit

Permalink
tools/nolibc: add support for waitid()
Browse files Browse the repository at this point in the history
waitid() is the modern variant of the family of wait-like syscalls.
Some architectures have dropped support for wait(), wait4() and waitpid()
but all of them support waitid().
It is more flexible and easier to use than the older ones.

Link: https://lore.kernel.org/r/20241221-nolibc-rv32-v1-1-d9ef6dab7c63@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
  • Loading branch information
Thomas Weißschuh committed Jan 13, 2025
1 parent 4b92b79 commit 7f89bc5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/include/nolibc/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/prctl.h>
#include <linux/resource.h>
#include <linux/utsname.h>
#include <linux/signal.h>

#include "arch.h"
#include "errno.h"
Expand Down Expand Up @@ -1225,6 +1226,23 @@ pid_t waitpid(pid_t pid, int *status, int options)
}


/*
* int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
*/

static __attribute__((unused))
int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage)
{
return my_syscall5(__NR_waitid, which, pid, infop, options, rusage);
}

static __attribute__((unused))
int waitid(int which, pid_t pid, siginfo_t *infop, int options)
{
return __sysret(sys_waitid(which, pid, infop, options, NULL));
}


/*
* ssize_t write(int fd, const void *buf, size_t count);
*/
Expand Down

0 comments on commit 7f89bc5

Please sign in to comment.