public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Luca Boccassi <luca.boccassi@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH v2 3/3] linux: Add pidfd_getpid
Date: Tue, 2 May 2023 17:19:26 +0100	[thread overview]
Message-ID: <CAMw=ZnSgpRzJNu3PWR7nZfzNjFwQYStb3FjpKQ2r4_GEXJy=fw@mail.gmail.com> (raw)
In-Reply-To: <87r0rysomw.fsf@oldenburg.str.redhat.com>

On Tue, 2 May 2023 at 17:07, Florian Weimer <fweimer@redhat.com> wrote:
>
> * Adhemerval Zanella via Libc-alpha:
> > diff --git a/sysdeps/unix/sysv/linux/pidfd_getpid.c b/sysdeps/unix/sysv/linux/pidfd_getpid.c
> > new file mode 100644
> > index 0000000000..d0c7987791
> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/pidfd_getpid.c
> > @@ -0,0 +1,94 @@
>
> > +static bool
> > +parse_fdinfo (const char *l, void *arg)
> > +{
> > +  enum { fieldlen = sizeof ("Pid:") - 1 };
> > +  if (strncmp (l, "Pid:", fieldlen) != 0)
> > +    return true;
> > +
> > +  l += fieldlen;
> > +
> > +  char *endp;
> > +  long int n = strtol (l, &endp, 10);
> > +  if (l == endp || n > INT_MAX)
> > +    return true;
>
> Should this use strtoul?  Otherwise I'm not sure the overflow check will
> work on 32-bit.
>
> Rest of the implementation looks okay, but the kernel should really
> provide an ioctl or similar for this.

This can be -1 when the process is gone, and it is important to get
that distinction (with certainty) to tell the caller ESRCH. We need
this distinction in callers.

Kind regards,
Luca Boccassi

  reply	other threads:[~2023-05-02 16:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 14:20 [PATCH v2 0/3] Add pidfd_spawn, pidfd_spawnp, pidfd_fork, and pidfd_getpid Adhemerval Zanella
2023-04-20 14:20 ` [PATCH v2 1/3] posix: Add pidfd_spawn and pidfd_spawnp (BZ# 30349) Adhemerval Zanella
2023-04-20 14:20 ` [PATCH v2 2/3] posix: Add pidfd_fork Adhemerval Zanella
2023-04-20 14:20 ` [PATCH v2 3/3] linux: Add pidfd_getpid Adhemerval Zanella
2023-04-20 14:24   ` Luca Boccassi
2023-05-02 16:07   ` Florian Weimer
2023-05-02 16:19     ` Luca Boccassi [this message]
2023-05-02 17:13       ` Florian Weimer
2023-05-15 17:39     ` Adhemerval Zanella Netto

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='CAMw=ZnSgpRzJNu3PWR7nZfzNjFwQYStb3FjpKQ2r4_GEXJy=fw@mail.gmail.com' \
    --to=luca.boccassi@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).