This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC v3 03/23] sysdeps/wait: Use waitid if avaliable
- From: Arnd Bergmann <arnd at arndb dot de>
- To: "Eric W. Biederman" <ebiederm at xmission dot com>
- Cc: Rich Felker <dalias at libc dot org>, Linus Torvalds <torvalds at linux-foundation dot org>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Florian Weimer <fweimer at redhat dot com>, Palmer Dabbelt <palmer at sifive dot com>, macro at wdc dot com, Zong Li <zongbox at gmail dot com>, Alistair Francis <alistair23 at gmail dot com>, Andrew Morton <akpm at linux-foundation dot org>, Al Viro <viro at zeniv dot linux dot org dot uk>, Christian Brauner <christian at brauner dot io>, "H. Peter Anvin" <hpa at zytor dot com>
- Date: Tue, 23 Jul 2019 10:12:07 +0200
- Subject: Re: [RFC v3 03/23] sysdeps/wait: Use waitid if avaliable
- References: <cover.1563321715.git.alistair.francis@wdc.com> <2d3359a195633b85e01f83bf536330d72f7bc8aa.1563321715.git.alistair.francis@wdc.com> <20190721040310.GA3283@brightrain.aerifal.cx> <CAK8P3a0bhS_d1SMyLQO_LDNvdgR+MKXmoESxWkrcz22mvjKcuw@mail.gmail.com> <87o91nbn37.fsf@xmission.com> <CAK8P3a3wgavtarKxSYJGL0ME9KRZ8UsUAZw+Y5J8WpG1GQ+=mw@mail.gmail.com> <87muh79yt2.fsf@xmission.com> <CAHk-=wjtGaJFceL+YB6=mTxQCvyNvBTavqgGTm-d5FA9xLQ0Cw@mail.gmail.com> <87blxn83sk.fsf@xmission.com> <20190721232336.GA30851@brightrain.aerifal.cx> <87k1c962ml.fsf@xmission.com>
On Tue, Jul 23, 2019 at 2:01 AM Eric W. Biederman <ebiederm@xmission.com> wrote:
> Rich Felker <dalias@libc.org> writes:
> > On Sun, Jul 21, 2019 at 04:40:27PM -0500, Eric W. Biederman wrote:
> >> Linus Torvalds <torvalds@linux-foundation.org> writes:
> > I'm in agreement that if an extension to the waitid syscall is added,
> > it should be P_PROCESS_PGID, not defining some special case for
> > pid==0. It's not entirely clear but arguable that the standard
> > requires EINVAL for P_PGID + pid==0, and plausible that there are
> > applications that depend on this. We could emulate the EINVAL case in
> > userspace, but assigning weird semantics to special cases is just a
> > mess of potential future headaches when it would be trivial to do it
> > right. And doing it right would also make programming userspace side
> > easier.
>
> Since this is a POSIX interface and shared between many unices I took
> at look at a couple to see what they have done. If possible it is
> important to be able to write programs that work the same across
> different unices.
>
> The BSDs implemented wait6 as their common wait that does everything
> system call. It's large contribution is that wait6 will give both
> the rusage of the child that exited and it's children separately.
Ah right, that was one more thing I forgot on my earlier list. If we end up
creating a new wait4()/waitid() replacement to replace the timeval
with __kernel_timespec, we may want that to return a wrusage instead
of rusage. Same for Christian's proposed pidfd_wait().
> So my recommendation now is to avoid gratuitous incompatibilities.
>
> 1) For extending waitid. Let's use P_PGID and and id of 0 to represent
> the callers process group. That is compatible with the BSDs, and
> portable programs should not have any problem with it.
>
> I want to stay away from the BSD extention of P_PID with an id of 0
> meaning wait for the calling process's process group. I see where
> it comes from but that is confusing.
>
> 2) It appears the popular definition of current process group is the
> current process group at the time of the system call. Currently that
> is Linux, FreeBSD, Illumos, and XNU. So short of a real program that
> cares, let's adopt that definition in linux. Along with patches I
> will see about getting the linux manpage updated to clarify that
> point.
That all sounds reasonable to me, thanks for researching the other
implementations!
Arnd