[Python-Dev] SIGPIPE => SIG_IGN?

Gustavo Niemeyer gustavo at niemeyer.net
Sat Sep 10 01:47:09 CEST 2005


Greetings,
I was wondering, why are we setting SIGPIPE to SIG_IGN
in initsigs():
 static void
 initsigs(void)
 {
 #ifdef SIGPIPE
 PyOS_setsig(SIGPIPE, SIG_IGN);
 #endif
 [...]
 }
One of the side effects is:
 >>> os.system("yes | read any")
 yes: standard output: Broken pipe
 yes: write error
 0
 >>> os.system("yes | head -1")
 y
 yes: standard output: Broken pipe
 yes: write error
 0
That stops when setting to SIG_DFL:
 >>> signal.signal(signal.SIGPIPE, signal.SIG_DFL)
 1
 >>> os.system("yes | head -1")
 y
 0
 >>> os.system("yes | read any")
 0
Out of curiosity, many of the google results for
"yes: standard output: Broken pipe" are from
Python programs. :-)
Regards,
-- 
Gustavo Niemeyer
http://niemeyer.net


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /