A tale of two execs

aha aquil.abdullah at gmail.com
Tue Feb 24 06:13:12 CET 2009

Hello All,
  It occurred to me that I might just want to try copying the
subprocess.py installed in a /usr/lib/python24 installation to the
directory where I place the scripts that I need to launch my
application...I know this was mentioned earlier.  Anyway, my
application worked under python 2.3 and later python versions as
well.  Here is what I did:

I renamed subprocess.py to subprocess23.py and then used the following

  import subprocess
except ImportError:
  import subprocess23 as subprocess

I chose this route because I took a deeper look at the code in the
subprocess module and I also realized that I would not be able to use
the popen2, because I would not be able to do things like os.setpgrp
for preexec_fn, with popen2.  In the end, if I wanted that type of
functionality I would have to use os.dup, fork, exec, which meant
reinventing the wheel.  I overcame the issue of dealing with msvcrt
and _subprocess under windows by requiring python24 or greater under


More information about the Python-list mailing list