You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FreeBSD /dev/fd/ behaves differently than Linux /dev/fd/. I'm not sure why. If the parent opens a file and the file descriptor is inherited, the child process can open the file, but /dev/fd/ only contains file descriptors 0, 1, 2. Example:
parent.py:
import subprocess
import sys
script = 'print("Hello")'
script_name = 'script.py'
with open(script_name, 'w') as fp:
fp.write(script)
with open(script_name, "r") as fp:
fd = fp.fileno()
print("FD", fd)
cmd = [sys.executable]
p = subprocess.Popen(cmd, close_fds=False, pass_fds=(0, 1, 2, fd))
p.wait()
Child process:
$ ./python y.py
FD 3
/usr/home/vstinner/python/main/Lib/subprocess.py:849: RuntimeWarning: pass_fds overriding close_fds.
warnings.warn("pass_fds overriding close_fds.", RuntimeWarning)
Python 3.12.0a2+ (heads/main:e3a3863cb9, Dec 5 2022, 12:09:39) [Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a3 on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
# The process has 4 file descriptors:
>>> fd=os.dup(0); os.close(fd)
>>> fd=os.dup(1); os.close(fd)
>>> fd=os.dup(2); os.close(fd)
>>> fd=os.dup(3); os.close(fd)
# But /dev/fd/3 doesn't exist
>>> os.listdir("/dev/fd")
['0', '1', '2']
>>> f=open("/dev/fd/3", "rb")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/dev/fd/3'
# Using directly file descriptor 3 works as expected:
>>> f=open(3, "rb")
>>> f.close()
…0006)
On FreeBSD, skip test_script_as_dev_fd() of test_cmd_line_script if
fdescfs is not mounted (at /dev/fd).
(cherry picked from commit 038b151)
Co-authored-by: Victor Stinner <vstinner@python.org>
On FreeBSD, skip test_script_as_dev_fd() of test_cmd_line_script if
fdescfs is not mounted (at /dev/fd).
(cherry picked from commit 038b151)
Co-authored-by: Victor Stinner <vstinner@python.org>
I propose to skip test_cmd_line_script.test_script_as_dev_fd() on FreeBSD. Here is why.
cc @Jehops @emaste @koobs
The test added by PR #99768 fails on FreeBSD. test_cmd_line_script.test_script_as_dev_fd() fails with:
Note: Failure first reported in issue #99985.
FreeBSD /dev/fd/ behaves differently than Linux /dev/fd/. I'm not sure why. If the parent opens a file and the file descriptor is inherited, the child process can open the file, but /dev/fd/ only contains file descriptors 0, 1, 2. Example:
parent.py:
Child process:
Linked PRs
The text was updated successfully, but these errors were encountered: