[PATCH 9/9] lib/procutils: reset errno before strtol() call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 lib/procutils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/procutils.c b/lib/procutils.c
index d633261..31b77ff 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;
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux