All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Dmitry V. Levin" <ldv@altlinux.org>,
	Albert ARIBAUD <albert.aribaud@3adev.fr>,
	"H. Peter Anvin" <hpa@zytor.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Linux API <linux-api@vger.kernel.org>
Subject: Re: extending wait4(2) or waitid(2) linux syscall
Date: Wed, 28 Nov 2018 10:31:23 +0100	[thread overview]
Message-ID: <87r2f5h7kk.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: CAK8P3a3pVS3_70PQ+SeiSZtqXFcb5HON0QGRypWfu=cfLPgN=w@mail.gmail.com

* Arnd Bergmann:

> On Mon, Nov 26, 2018 at 4:18 PM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * Arnd Bergmann:
>>
>> > On Thu, Nov 15, 2018 at 7:30 AM Dmitry V. Levin <ldv@altlinux.org> wrote:
>> >> On Thu, Nov 15, 2018 at 06:39:03AM -0800, Arnd Bergmann wrote:
>> >> > On Thu, Nov 15, 2018 at 6:05 AM Dmitry V. Levin wrote:
>> >> > > On Thu, Apr 20, 2017 at 03:20:51PM +0200, Albert ARIBAUD wrote:
>> >>
>> >> 1. strace needs a race-free invocation of wait4(2) or waitid(2)
>> >> with a different signal mask, this cannot be achieved without
>> >> an extended version of syscall, similar to pselect6(2) extension
>> >> over select(2) and ppoll(2) extension over poll(2).
>> >>
>> >> Signal mask specification in linux requires two parameters:
>> >> "const sigset_t *sigmask" and "size_t sigsetsize".
>> >> Creating pwait6(2) as an extension of wait4(2) with two arguments
>> >> is straightforward.
>> >> Creating pwaitid(2) as an extension of waitid(2) that already has 5
>> >> arguments would require an indirection similar to pselect6(2).
>> >
>> > Getting back to this point: you could also do the same thing with
>> > the CLONE_FD approach from Josh Triplett[1] or Casey Dahlin's
>> > older waitfd() syscall, correct?
>>
>> A descriptor-based solution would not be useful to glibc because
>> applications assume that glibc does not (persistently) open any file
>> descriptors behind t heir back.
>
> Right, makes sense. What about a temporary file descriptor as discussed
> in the recent procfd() mail thread then? Would that work?
>
> /* for illustration, needs error handling and more features */
> int pwait(pid_t id, siginfo_t *infop)
> {
>       char waitfd_file[MAX_PROCFD_LEN];
>       struct pollfd pfd[1] = { {.events = POLLIN }};
>
>       snprintf(waitfd_file, MAX_PROCFD_LEN, "/proc/%d/wait", pid);
>       pfd.fd = open(waitfd_file,  O_RDONLY);
>       ppoll(&pfd, 1, NULL, sigmask);
>       read(fd, infop, sizeof(*infop));
>       close(fd);
>
>      return 0;
> }

Together with an officiall supported way that allows us that the process
denoted by the PID is still the same that it was, it could work, I
think.

It would also nice to have the ability to launch processes without
making them visible to wait, and trigger SIGCHLD signals, but noticing
process exit seems like a tricky matter under these circumstances.

Thanks,
Florian

  parent reply	other threads:[~2018-11-28  9:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170420152051.568f2050.albert.aribaud@3adev.fr>
     [not found] ` <20181115140441.GA2171@altlinux.org>
     [not found]   ` <CAK8P3a0Gsqa8WTbALOUchRyEA7E2f3P1f=XQ8nD2xQaemfPpcQ@mail.gmail.com>
2018-11-15 15:30     ` extending wait4(2) or waitid(2) linux syscall Dmitry V. Levin
2018-11-15 15:37       ` hpa
2018-11-16  7:14         ` Arnd Bergmann
2018-11-16 10:26           ` Florian Weimer
2018-11-16 15:17             ` Arnd Bergmann
2018-11-16 16:03               ` Paul Eggert
2018-11-16 18:46           ` hpa
2018-11-16 18:48           ` hpa
2018-11-16  7:12       ` Arnd Bergmann
2018-11-16 12:42       ` Dave Martin
2018-11-16 13:40         ` Florian Weimer
2018-11-16 14:26           ` Dave Martin
2018-11-17  1:50       ` Arnd Bergmann
2018-11-26 15:18         ` Florian Weimer
2018-11-26 17:15           ` Arnd Bergmann
2018-11-26 17:27             ` Daniel Colascione
2018-11-28  9:31             ` Florian Weimer [this message]
2018-11-28  9:36               ` Christian Brauner
2018-11-28  9:41                 ` Florian Weimer
2018-11-28 18:50                   ` Daniel Colascione

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r2f5h7kk.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=albert.aribaud@3adev.fr \
    --cc=arnd@arndb.de \
    --cc=hpa@zytor.com \
    --cc=ldv@altlinux.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.