[Tutor] "standard output: Broken pipe"
alan.gauld at btinternet.com
Sun Oct 21 01:34:31 CEST 2007
"James" <jtp at nc.rr.com> wrote
> signal.signal(signal.SIGPIPE, signal.SIG_DFL)
> Before the snippet of code I included in my original e-mail
> (subprocess.call( "yes '' | make oldconfig" , shell=True )) got rid
> of the error. I can't seem to figure out precisely what the
> signal.signal() function does (as shown above).
A signal is basically an interrupt. Its raised by the OS.
signal.signal catches the named signal(s) and handles it.
The default handler appears to just swallow the signal
Its a bit like, in Python, doing
except SomeError: pass
The except clause catches the error but ignores it.
signal.signal is doing much the same but at the OS level.
My personal approach is to avoid using signal to trap
and ignore signals since they can be needed by other
processes running concurrently on the machine,
but in this case it appears harmless. But in general,
any approach which could interfere in unpredicable
ways with other processes on the computer is a
risky strategy IMHO.
More information about the Tutor