mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-31 22:25:25 -04:00
Use /dev/fd instead of /proc/self/fd
/dev/fd exists on all operating systems I can test (Linux, FreeBSD, macOS), whereas /proc/self/fd only appears to exist on Linux. Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
This commit is contained in:
parent
5a981ee823
commit
644efe9517
1 changed files with 7 additions and 3 deletions
|
|
@ -48,8 +48,12 @@ count_open_fds(void)
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
dir = opendir("/proc/self/fd");
|
/*
|
||||||
assert(dir && "opening /proc/self/fd failed.");
|
* Using /dev/fd instead of /proc/self/fd should allow this code to
|
||||||
|
* work on non-Linux operating systems.
|
||||||
|
*/
|
||||||
|
dir = opendir("/dev/fd");
|
||||||
|
assert(dir && "opening /dev/fd failed.");
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
while ((ent = readdir(dir))) {
|
while ((ent = readdir(dir))) {
|
||||||
|
|
@ -58,7 +62,7 @@ count_open_fds(void)
|
||||||
continue;
|
continue;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
assert(errno == 0 && "reading /proc/self/fd failed.");
|
assert(errno == 0 && "reading /dev/fd failed.");
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue