Blocking ctrl-c to os.popen() or os.system()

Sandeep Gupta sandeep182 at hotmail.com
Sat Jan 4 17:00:35 EST 2003


I am executing a command from python via os.popen().  While the
command is executing, if I type ctrl-c, the command receives the
interrupt.  I would like to block the ctrl-c from the command and I've
tried the following:

1)Using python's signal module to ignore SIGINT.  This causes python
to ignore SIGINT, but a ctrl-c that is typed during the popen() call
still goes to the command.

2)Adding "< /dev/null" to the os.popen() call.  This doesn't help.

3)Using popen2() and immediately closing the stdin file.  This also
doesn't work.

Any suggestions would be greatly appreciated!

Thanks
Sandeep




More information about the Python-list mailing list