aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/support/os_helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/support/os_helper.py')
-rw-r--r--Lib/test/support/os_helper.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/support/os_helper.py b/Lib/test/support/os_helper.py
index 46ae53aa11a..7a67d87fb9e 100644
--- a/Lib/test/support/os_helper.py
+++ b/Lib/test/support/os_helper.py
@@ -592,10 +592,17 @@ def fd_count():
"""Count the number of open file descriptors.
"""
if sys.platform.startswith(('linux', 'freebsd', 'emscripten')):
+ fd_path = "/proc/self/fd"
+ elif sys.platform == "darwin":
+ fd_path = "/dev/fd"
+ else:
+ fd_path = None
+
+ if fd_path is not None:
try:
- names = os.listdir("/proc/self/fd")
+ names = os.listdir(fd_path)
# Subtract one because listdir() internally opens a file
- # descriptor to list the content of the /proc/self/fd/ directory.
+ # descriptor to list the content of the directory.
return len(names) - 1
except FileNotFoundError:
pass