ignoring SIGPIPE in a python script?

Dan Stromberg strombrg at dcs.nac.uci.edu
Tue May 31 21:26:57 EDT 2005


I have a python script that sometimes gets a SIGPIPE signal, and errors
out.  And I want it to just terminate as though it had hit EOF.

I'm running:

   signal.signal(signal.SIGPIPE,signal.SIG_IGN)

...in the main function, but the script is still erroring out on sigpipe
when the consumer to its producer terminates early.

Am I going to have to code in a handful of exceptions, and then
conditionalize what happens in those exception handlers, to get the
desired behavior?

ISTR hearing that although bash notifies one of SIGPIPE errors, tcsh
generally silently ignores them.  From this, I conclude that it might be
reasonable for my script to ignore SIGPIPE.

Thanks!




More information about the Python-list mailing list