]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/procutils: reset errno before strtol() call
authorSami Kerola <kerolasa@iki.fi>
Tue, 15 Apr 2014 10:54:21 +0000 (11:54 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 26 Apr 2014 18:04:57 +0000 (19:04 +0100)
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 <kerolasa@iki.fi>
lib/procutils.c

index d633261efab3e181474000f31f75e647eff46f9f..31b77ff35950550608f0d93bc2c9681e0e02e010 100644 (file)
@@ -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;