This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] libdwfl: linux-pid-attach.c: Report actual PID (Tgid) to dwfl_attach_state.
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 02 Jan 2014 16:24:04 +0100
- Subject: Re: [PATCH] libdwfl: linux-pid-attach.c: Report actual PID (Tgid) to dwfl_attach_state.
On Wed, 25 Dec 2013 23:10:50 +0100, Mark Wielaard wrote:
> On Wed, Dec 25, 2013 at 08:23:25PM +0100, Jan Kratochvil wrote:
> > On Mon, 23 Dec 2013 14:22:24 +0100, Mark Wielaard wrote:
> > > + {
> > > + pid = atoi (&buffer[5]);
> > > + break;
> > > + }
> > > + fclose (procfile);
> > > +
> > > + if (pid == 0)
> > > + return false;
> >
> > I do not understand this conditional. If "Tgid:" was not found PID will be
> > the user-specified TID, not 0.
>
> It would be zero in the very unlikely case atoi doesn't see any digits.
If you want to check /proc files validity there should be strtol and not atoi.
"Tgid: 42foo\n" still gets parsed as 42 by the code above.
Regards,
Jan