]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
procutils: reset errno before readdir
authorRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 8 May 2015 22:47:33 +0000 (00:47 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 16 Jun 2015 14:22:26 +0000 (16:22 +0200)
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@ga-group.nl>
lib/procutils.c

index ef969417dd665e115896b5c9758b56ff625cf20f..1823d16b1b1e9a73d2b6610df3c071f29f94252c 100644 (file)
@@ -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 */