Message173804
When subprocess.Popen is called with subprocess.PIPE and os.fork() fails (due to insufficient memory for example), the pipes created by _get_handles() are not closed.
Steps to reproduce:
1) Launch a python shell, import subprocess
2) Create a situation where os.fork() will fail (I ran a program to eat up nearly all of the memory on a system)
3) subprocess.Popen('/bin/echo', stdin=subprocess.PIPE)
4) OSError(12, 'Cannot allocate memory')
5) ls /proc/$pid/fd , There are now extra pipes.
I tested on Ubuntu 11.10 python (2.7.2-5ubuntu1). My reading of the 2.7 and 3.3 development trees suggest that this is an issue with both of those branches, but I don't have a 3.3 installation to confirm with.
I've attached a snippet that fixes it for my version of Python on Ubuntu. No idea what ramifications it will have for other versions/OS/etc. No automated testing included because I'm not entirely sure how to replicate this without eating up a ton of ram or doing something naughty with ulimit. |
|
Date |
User |
Action |
Args |
2012-10-25 22:31:03 | Mark.Gius | set | recipients:
+ Mark.Gius |
2012-10-25 22:31:03 | Mark.Gius | set | messageid: <1351204263.29.0.689540716038.issue16327@psf.upfronthosting.co.za> |
2012-10-25 22:31:03 | Mark.Gius | link | issue16327 messages |
2012-10-25 22:31:02 | Mark.Gius | create | |
|