1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

linux: Use waitid on wait4 if __NR_wait4 is not defined

If the wait4 syscall is not available (such as y2038 safe 32-bit
systems) waitid should be used instead.  However prior Linux 5.4
waitid is not a full superset of other wait syscalls, since it
does not include support for waiting for the current process group.

It is possible to emulate wait4 by issuing an extra syscall to get
the current process group, but it is inherent racy: after the current
process group is received and before it is passed to waitid a signal
could arrive causing the current process group to change.

So waitid is used if wait4 is not defined iff the build is
enabled with a minimum kernel if 5.4+.  The new assume
__ASSUME_WAITID_PID0_P_PGID is added and an error is issued if waitid
can not be implemented by either __NR_wait4 or
__NR_waitid && __ASSUME_WAITID_PID0_P_PGID.

Checked on x86_64-linux-gnu and i686-linux-gnu.

Co-authored-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
Adhemerval Zanella
2019-11-13 17:45:13 -03:00
parent c5cbdacb8a
commit 9b2cf9482a
3 changed files with 90 additions and 1 deletions

View File

@ -208,4 +208,10 @@
# define __ASSUME_TIME64_SYSCALLS 1
#endif
/* Linux waitid prior kernel 5.4 does not support waiting for the current
process group. */
#if __LINUX_KERNEL_VERSION >= 0x050400
# define __ASSUME_WAITID_PID0_P_PGID
#endif
#endif /* kernel-features.h */