mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
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).
This commit is contained in:
@ -24,3 +24,11 @@
|
|||||||
/* Bits in the third argument to `waitpid'. */
|
/* Bits in the third argument to `waitpid'. */
|
||||||
#define WNOHANG 1 /* Don't block waiting. */
|
#define WNOHANG 1 /* Don't block waiting. */
|
||||||
#define WUNTRACED 2 /* Report status of stopped children. */
|
#define WUNTRACED 2 /* Report status of stopped children. */
|
||||||
|
|
||||||
|
/* Bits in the fourth argument to `waitid'. */
|
||||||
|
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
|
||||||
|
# define WSTOPPED WUNTRACED /* Report stopped child. */
|
||||||
|
# define WCONTINUED 4 /* Report continued child. */
|
||||||
|
# define WNOWAIT 8 /* Don't reap, just poll status. */
|
||||||
|
# define WEXITED 16 /* Report dead child. */
|
||||||
|
#endif
|
||||||
|
@ -8,8 +8,7 @@ constant WUNTRACED
|
|||||||
|
|
||||||
macro WEXITSTATUS
|
macro WEXITSTATUS
|
||||||
# if !defined XPG4 && !defined POSIX && !defined POSIX2008
|
# if !defined XPG4 && !defined POSIX && !defined POSIX2008
|
||||||
// Bug 23091: hurd: missing waitid support.
|
macro WIFCONTINUED
|
||||||
xfail[i386-gnu]-macro WIFCONTINUED
|
|
||||||
# endif
|
# endif
|
||||||
macro WIFEXITED
|
macro WIFEXITED
|
||||||
macro WIFSIGNALED
|
macro WIFSIGNALED
|
||||||
@ -17,15 +16,14 @@ macro WIFSTOPPED
|
|||||||
macro WSTOPSIG
|
macro WSTOPSIG
|
||||||
macro WTERMSIG
|
macro WTERMSIG
|
||||||
|
|
||||||
// Bug 23091: hurd: missing waitid support.
|
|
||||||
# if !defined XPG4 && !defined POSIX
|
# if !defined XPG4 && !defined POSIX
|
||||||
xfail[i386-gnu]-constant WEXITED
|
constant WEXITED
|
||||||
xfail[i386-gnu]-constant WSTOPPED
|
constant WSTOPPED
|
||||||
# ifndef POSIX2008
|
# ifndef POSIX2008
|
||||||
xfail[i386-gnu]-constant WCONTINUED
|
constant WCONTINUED
|
||||||
# endif
|
# endif
|
||||||
constant WNOHANG
|
constant WNOHANG
|
||||||
xfail[i386-gnu]-constant WNOWAIT
|
constant WNOWAIT
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#if !defined XPG4 && !defined POSIX
|
#if !defined XPG4 && !defined POSIX
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Pseudo implementation of waitid.
|
/* Implementation of waitid. Hurd version.
|
||||||
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1997.
|
Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1997.
|
||||||
@ -18,14 +18,23 @@
|
|||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <hurd.h>
|
||||||
|
#include <hurd/port.h>
|
||||||
|
#include <hurd/version.h>
|
||||||
|
#include <sysdep-cancel.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
__waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
|
__waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
|
||||||
{
|
{
|
||||||
|
struct rusage ignored;
|
||||||
|
error_t err;
|
||||||
pid_t pid, child;
|
pid_t pid, child;
|
||||||
|
int sigcode;
|
||||||
int status;
|
int status;
|
||||||
|
int cancel_oldtype;
|
||||||
|
|
||||||
switch (idtype)
|
switch (idtype)
|
||||||
{
|
{
|
||||||
@ -59,16 +68,19 @@ __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note the waitid() is a cancellation point. But since we call
|
cancel_oldtype = LIBC_CANCEL_ASYNC();
|
||||||
waitpid() which itself is a cancellation point we do not have
|
#if HURD_INTERFACE_VERSION >= 20201227
|
||||||
to do anything here. */
|
err = __USEPORT_CANCEL (PROC, __proc_waitid (port, pid, options,
|
||||||
child = __waitpid (pid, &status, 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)
|
if (err == EAGAIN)
|
||||||
/* `waitpid' set `errno' for us. */
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (child == 0)
|
|
||||||
{
|
{
|
||||||
/* POSIX.1-2008, Technical Corrigendum 1 XSH/TC1-2008/0713 [153] states
|
/* POSIX.1-2008, Technical Corrigendum 1 XSH/TC1-2008/0713 [153] states
|
||||||
that if waitid returns because WNOHANG was specified and status is
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (err != 0)
|
||||||
|
return __hurd_fail (err);
|
||||||
|
|
||||||
/* Decode the status field and set infop members... */
|
/* Decode the status field and set infop members... */
|
||||||
infop->si_signo = SIGCHLD;
|
infop->si_signo = SIGCHLD;
|
||||||
infop->si_pid = child;
|
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_code = CLD_STOPPED;
|
||||||
infop->si_status = WSTOPSIG (status);
|
infop->si_status = WSTOPSIG (status);
|
||||||
}
|
}
|
||||||
|
else if (WIFCONTINUED (status))
|
||||||
|
{
|
||||||
|
infop->si_code = CLD_CONTINUED;
|
||||||
|
infop->si_status = SIGCONT;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user