From f6abd970284a06380cd9d905f43da104bd49fc95 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 28 Dec 2020 23:37:04 +0100 Subject: hurd: Add WSTOPPED/WCONTINUED/WEXITED/WNOWAIT support [BZ #23091] The new __proc_waitid RPC now expects WEXITED to be passed, allowing to properly implement waitid, and thus define the missing W* macros (according to FreeBSD values). --- sysdeps/mach/hurd/waitid.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'sysdeps/mach') diff --git a/sysdeps/mach/hurd/waitid.c b/sysdeps/mach/hurd/waitid.c index 044a1dd8e3..eb5141e351 100644 --- a/sysdeps/mach/hurd/waitid.c +++ b/sysdeps/mach/hurd/waitid.c @@ -1,4 +1,4 @@ -/* Pseudo implementation of waitid. +/* Implementation of waitid. Hurd version. Copyright (C) 1997-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg , 1997. @@ -18,14 +18,23 @@ . */ #include +#include #include #include +#include +#include +#include +#include int __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) { + struct rusage ignored; + error_t err; pid_t pid, child; + int sigcode; int status; + int cancel_oldtype; switch (idtype) { @@ -59,16 +68,19 @@ __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) return -1; } - /* Note the waitid() is a cancellation point. But since we call - waitpid() which itself is a cancellation point we do not have - to do anything here. */ - child = __waitpid (pid, &status, options); + cancel_oldtype = LIBC_CANCEL_ASYNC(); +#if HURD_INTERFACE_VERSION >= 20201227 + err = __USEPORT_CANCEL (PROC, __proc_waitid (port, pid, options, + &status, &sigcode, + &ignored, &child)); + if (err == MIG_BAD_ID || err == EOPNOTSUPP) +#endif + err = __USEPORT_CANCEL (PROC, __proc_wait (port, pid, options, + &status, &sigcode, + &ignored, &child)); + LIBC_CANCEL_RESET (cancel_oldtype); - if (child == -1) - /* `waitpid' set `errno' for us. */ - return -1; - - if (child == 0) + if (err == EAGAIN) { /* POSIX.1-2008, Technical Corrigendum 1 XSH/TC1-2008/0713 [153] states that if waitid returns because WNOHANG was specified and status is @@ -80,6 +92,9 @@ __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) return 0; } + if (err != 0) + return __hurd_fail (err); + /* Decode the status field and set infop members... */ infop->si_signo = SIGCHLD; infop->si_pid = child; @@ -100,6 +115,11 @@ __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) infop->si_code = CLD_STOPPED; infop->si_status = WSTOPSIG (status); } + else if (WIFCONTINUED (status)) + { + infop->si_code = CLD_CONTINUED; + infop->si_status = SIGCONT; + } return 0; } -- cgit 1.4.1