Re: [RFC PATCH] pidfd: implement PIDFD_THREAD flag for pidfd_open()

From: Andy Lutomirski
Date: Wed Jan 31 2024 - 13:12:17 EST


On Mon, Jan 29, 2024 at 3:24 AM Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> On 01/27, Oleg Nesterov wrote:
> >
> > I'll (hopefully) send v2 on top of
> >
> > pidfd: cleanup the usage of __pidfd_prepare's flags
> > pidfd: don't do_notify_pidfd() if !thread_group_empty()
> >
> > on Monday
>
> Sorry, I don't have time to finish v2 today, I need to update the comments
> and write the changelog.
>
> But the patch itself is ready, I am sending it for review.
>
> Tycho, Christian, any comments?

Right now, pidfd_send_signal() sends signals to processes, like so:

* The syscall currently only signals via PIDTYPE_PID which covers
* kill(<positive-pid>, <signal>. It does not signal threads or process
* groups.

This patch adds PIDFD_THREAD which, potentially confusingly, doesn't
change this (AFAICS). So at least that should be documented loudly
and clearly, IMO. But I actually just bumped in to this limitation in
pidfd_send_signal(), like so:

https://github.com/systemd/systemd/issues/31093

Specifically, systemd can't properly emulate Ctrl-C using pidfd_send_signal().

I don't know whether implementing the other signal types belongs as
part of this patch, but they're at least thematically related.

--Andy