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
{{ message }}
This repository was archived by the owner on Oct 27, 2022. It is now read-only.
importosimportsysifos.name=='posix'andsys.version_info[0] <3:
importsubprocess32assubprocesselse:
importsubprocessp1=subprocess.Popen(['echo', 'hi'], stdout=subprocess.PIPE)
p2=subprocess.Popen(['echo', 'bye'], stdout=subprocess.PIPE)
# uncommenting these lines will produce expected result in python2.7# subprocess._set_cloexec(p1.stdout.fileno(), False)# subprocess._set_cloexec(p2.stdout.fileno(), False)subs= [p1, p2]
fds= [i.stdout.fileno() foriinsubs]
args= ['/dev/fd/{}'.format(fd) forfdinfds]
p2=subprocess.Popen(
['cat'] +args,
pass_fds=fds
)
python 3.5 output:
hi
bye
python 2.7 output:
cat: /dev/fd/3: No such file or directory
cat: /dev/fd/4: No such file or directory
My C isn't very good, but I traced through the _posixsubprocess.c and fileutils.c source on the 2.7 tag of cpython sources on GitHub, and it looks like it should be calling ioctl(fd, FIONCLEX, NULL) for each fd in pass_fds, so I haven't been able to figure out why this isn't working in python 2.7.