minix/minix/lib/libc/sys/wait4.c
David van Moolenbroek 29346ab043 PM: add support for wait4(2)
This patch adds support for the wait4 system call, and with that the
wait3 call as well.  The implementation is absolutely minimal: only
user and system times of the exited child are returned (with all other
rusage fields left zero), and there is no support for tracers.  Still,
this should cover the main use cases of wait4.

Change-Id: I7a04589a8423a23990ab39aa38e85d535556743a
2015-09-29 18:15:28 +00:00

27 lines
523 B
C

#include <sys/cdefs.h>
#include <lib.h>
#include "namespace.h"
#include <string.h>
#include <sys/wait.h>
#ifdef __weak_alias
__weak_alias(wait4, __wait450)
#endif
pid_t
wait4(pid_t pid, int * status, int options, struct rusage * rusage)
{
message m;
memset(&m, 0, sizeof(m));
m.m_lc_pm_wait4.pid = pid;
m.m_lc_pm_wait4.options = options;
m.m_lc_pm_wait4.addr = (vir_bytes)rusage;
if (_syscall(PM_PROC_NR, PM_WAIT4, &m) < 0) return(-1);
if (status != NULL) *status = m.m_pm_lc_wait4.status;
return m.m_type;
}