subprocess.Popen not replacing current process?

goodman goodman.m.w at gmail.com
Thu Nov 4 09:22:09 CET 2010


Note: Our server is a Linux machine, but we're restricted to Python
2.4.

Hi, I'm wondering why subprocess.Popen does not seem to replace the
current process, even when it uses os.execvp (according to the
documentation: http://docs.python.org/library/subprocess.html#subprocess.Popen).
Specifically, when I try to kill a spawned process with Ctrl-C, the
SIGINT does not seem to be sent to the spawned process.

Some background: I have a Python script that calls shell scripts or
commands. It does not need to regain control after calling these
scripts or commands, so up to now I've been using an os.exec* command.
It seems the subprocess module is the recommended way for spawning
processes, but in this case perhaps it's better I stick with os.exec*?
I've seen plenty of discussion about catching KeyboardInterrupt in the
parent process and then manually killing the child, but (1) I can't
use Popen.kill() on Python 2.4, and (2) this level of process
management seems like overkill (pardon the potential for puns) in my
case.

Thanks for any help.



More information about the Python-list mailing list