Thread (8 messages) read the whole thread 8 messages, 4 authors, 2024-10-01

Re: [RFC PATCH 0/3] introduce PIDFD_SELF

From: Lorenzo Stoakes <hidden>
Date: 2024-09-30 10:40:11
Also in: linux-fsdevel, linux-kselftest, linux-mm, lkml

On Mon, Sep 30, 2024 at 12:33:18PM GMT, Florian Weimer wrote:
* Lorenzo Stoakes:
quoted
If you wish to utilise a pidfd interface to refer to the current process
(from the point of view of userland - from the kernel point of view - the
thread group leader), it is rather cumbersome, requiring something like:

	int pidfd = pidfd_open(getpid(), 0);

	...

	close(pidfd);

Or the equivalent call opening /proc/self. It is more convenient to use a
sentinel value to indicate to an interface that accepts a pidfd that we
simply wish to refer to the current process.
The descriptor will refer to the current thread, not process, right?
No it refers to the current process (i.e. thread group leader from kernel
perspective). Unless you specify PIDFD_THREAD, this is the same if you did the above.
The distinction matters for pidfd_getfd if a process contains multiple
threads with different file descriptor tables, and probably for
pidfd_send_signal as well.
You mean if you did a strange set of flags to clone()? Otherwise these are
shared right?

Again, we are explicitly looking at process not thread from userland
perspective. A PIDFD_SELF_THREAD might be possible, but this series doesn't try
to implement that.
Thanks,
Florian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help