Fix fdwalk

It turns out you can't readdir from an O_PATH file-descriptor, so
fdwalk didn't work. Spotted the BADFD in a strace.

Closes: #60
Approved by: cgwalters
This commit is contained in:
Alexander Larsson
2016-05-09 16:27:33 +02:00
committed by Colin Walters (automation)
parent bf6e3564a3
commit b9c39e5beb

View File

@@ -262,7 +262,7 @@ fdwalk (int proc_fd, int (*cb)(void *data, int fd), void *data)
int res = 0;
DIR *d;
dfd = openat (proc_fd, "self/fd", O_DIRECTORY | O_PATH);
dfd = openat (proc_fd, "self/fd", O_DIRECTORY | O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY);
if (dfd == -1)
return res;