From: Emanuele Torre <torreemanuele6@gmail.com>
To: Alejandro Colomar <alx@kernel.org>
Cc: linux-man@vger.kernel.org, libc-alpha@vger.kernel.org
Subject: Re: pidfd_open.2: PIDFD_NONBLOCK is not defined by the listed headers
Date: Mon, 20 May 2024 11:12:45 +0200 [thread overview]
Message-ID: <ZksUDXCkKeVdIBox@t420> (raw)
In-Reply-To: <e4avr4d44fpkqtby6i53qthlkvhvum7fxkq63hkmuqtqgougyr@cropbgglzx2a>
On Mon, May 20, 2024 at 10:29:12AM +0200, Alejandro Colomar wrote:
> On Mon, May 20, 2024 at 07:02:39AM GMT, Emanuele Torre wrote:
> > So probably the best solution is to just make the pidfd_open(2),
> > pidfd_send_signal(2), and pidfd_getfd(2) man pages tell users to include
> > sys/pidfd.h and call the GNU libc functions instead of including
> > sys/syscall.h and unistd.h and calling syscall(2) directly; now that
> > sys/pidfd.h exists.
>
> Ahh, interesting. I'm using glibc 2.38 and still don't have that one.
> It seems added in 2.39. We can directly document that in
> pidfd_getfd(2).
>
> > And maybe to also add a pidfd_getpid(3) man page for the new pidfd
> > helper function.
>
> No, usually we document the glibc wrapper in man2, unless there's a big
> difference between the kernel syscall and the glibc wrapper.
pidfd_getpid() does not have much to do with pidfd_getfd(2), and it does
not call pidfd_* syscalls either.
As far as I understand (I have never tried to use it in a program),
pid_t pid = pidfd_getfd(pidfd);
Is equivalent to the following command in shell:
pid=$(grep -Pom1 '^Pid:\t\K.*' /proc/self/fdinfo/"$pidfd" || echo -1)
It reads the /proc/self/fdinfo file corresponding to the given fd and
returns the value of the "Pid" field as a pid_t, or -1.
o/
emanuele6
next prev parent reply other threads:[~2024-05-20 9:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 5:02 pidfd_open.2: PIDFD_NONBLOCK is not defined by the listed headers Emanuele Torre
2024-05-20 8:29 ` Alejandro Colomar
2024-05-20 8:53 ` Alejandro Colomar
2024-05-20 11:35 ` Adhemerval Zanella Netto
2024-11-01 13:27 ` Alejandro Colomar
2024-05-20 9:12 ` Emanuele Torre [this message]
2024-05-20 9:42 ` Alejandro Colomar
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=ZksUDXCkKeVdIBox@t420 \
--to=torreemanuele6@gmail.com \
--cc=alx@kernel.org \
--cc=libc-alpha@vger.kernel.org \
--cc=linux-man@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.