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

Michael Hudson mwh at python.net
Tue Jan 14 09:40:22 EST 2003


sandeep182 at hotmail.com (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.

Cheers,
M.

-- 
  A.D. 1517: Martin Luther nails his 95 Theses to the church door and
             is promptly moderated down to (-1, Flamebait).
        -- http://slashdot.org/comments.pl?sid=01/02/09/1815221&cid=52
                                        (although I've seen it before)




More information about the Python-list mailing list