From: Sami Kerola Date: Tue, 15 Apr 2014 10:54:21 +0000 (+0100) Subject: lib/procutils: reset errno before strtol() call X-Git-Tag: v2.25-rc1~244^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5889fbe592457afa51da684df9337f1588469ffa;p=thirdparty%2Futil-linux.git lib/procutils: reset errno before strtol() call When going through /proc the last entry made readdir() to alter errno, which made the strtol() to think something went wrong, resulting kill(1) tests to fail when running in --parallel mode. Signed-off-by: Sami Kerola --- diff --git a/lib/procutils.c b/lib/procutils.c index d633261efa..31b77ff359 100644 --- a/lib/procutils.c +++ b/lib/procutils.c @@ -86,7 +86,7 @@ int proc_next_tid(struct proc_tasks *tasks, pid_t *tid) if (!isdigit((unsigned char) *d->d_name)) continue; - + errno = 0; *tid = (pid_t) strtol(d->d_name, &end, 10); if (errno || d->d_name == end || (end && *end)) return -1; @@ -183,6 +183,7 @@ int proc_next_pid(struct proc_processes *ps, pid_t *pid) } p = NULL; + errno = 0; *pid = (pid_t) strtol(d->d_name, &p, 10); if (errno || d->d_name == p || (p && *p)) return errno ? -errno : -1;