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

Michael Hudson mwh at
Tue Jan 14 15:40:22 CET 2003

sandeep182 at (Sandeep Gupta) writes:

> 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.

That's surprising, to me at least.  I thought the exec* functions left
SIG_IGN signal destinations alone.  Does popen reset them?  The linux
manpage doesn't give any indication of doing so.


  A.D. 1517: Martin Luther nails his 95 Theses to the church door and
             is promptly moderated down to (-1, Flamebait).
                                        (although I've seen it before)

More information about the Python-list mailing list