[PATCH 1/2] procutils: reset errno before readdir

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

 



From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>

readdir(3p): "When the end of the directory is encountered, a null
pointer shall be returned and errno is not changed"

Signed-off-by: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
---
 lib/procutils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/procutils.c b/lib/procutils.c
index ef96941..1823d16 100644
--- a/lib/procutils.c
+++ b/lib/procutils.c
@@ -143,6 +143,7 @@ int proc_next_pid(struct proc_processes *ps, pid_t *pid)
 	do {
 		char buf[BUFSIZ], *p;
 
+		errno = 0;
 		d = readdir(ps->dir);
 		if (!d)
 			return errno ? -1 : 1;		/* error or end-of-dir */
-- 
1.8.4.5

--
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