Message123790
The patch doesn't seem to work.
I added this before closerange in _close_all_but_a_sorted_few_fds:
print("Closing", start_fd, "up to", fd, "exclusive")
And used the attached script to run as a subprocess to check for open fds (taken from my tests patch for issue 7213).
Here's the result:
Python 3.2b1 (py3k:87158M, Dec 11 2010, 02:55:28)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
>>> import subprocess
>>> subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=False).wait()
0,1,2
0
>>> os.pipe()
(3, 4)
>>> os.pipe()
(5, 6)
>>> subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=False).wait()
0,1,2,3,4,5,6
0
>>> subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True).wait()
0,1,2
0
>>> subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, pass_fds=(6,)).wait()
0,1,2,6
0
>>> subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, pass_fds=(3,)).wait()
0,1,2
0
>>> subprocess._posixsubprocess = None
>>> subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, pass_fds=(6,)).wait()
Closing 3 up to 6 exclusive
Closing 7 up to 8 exclusive
0,1,2,6
0
>>> subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, pass_fds=(3,)).wait()
Closing 3 up to 8 exclusive
0,1,2
0
I also attach a possible test for pass_fds, and an example fix for Python-only implementation. The test requires either my tests patch for issue 7213, or the attached fd_status.py to be put in subprocessdata subdir of Lib/test. The fixed Python implementation passes my test and works fine in the console, I haven't tried the C one. (I don't have a patch for the fix, since it would conflict with the patches for issue 7213.) |
|
Date |
User |
Action |
Args |
2010-12-11 14:04:55 | milko.krachounov | set | recipients:
+ milko.krachounov, gregory.p.smith, amaury.forgeotdarc, pitrou, zhigang |
2010-12-11 14:04:55 | milko.krachounov | set | messageid: <1292076295.65.0.903798589953.issue6559@psf.upfronthosting.co.za> |
2010-12-11 14:04:53 | milko.krachounov | link | issue6559 messages |
2010-12-11 14:04:53 | milko.krachounov | create | |
|