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