Unbuffer stdout?

Donn Cave donn at u.washington.edu
Thu Mar 27 19:10:08 CET 2003


Quoth "Greg Ewing (using news.cis.dfn.de)" <me at privacy.net>:
| Donn Cave wrote:
|> Another peculiarity I noticed when I tried this out - on some
|> platforms, when you run "yes" with popen2(), the process even
|> survives its python parent, and not only survives but becomes
|> very active.  This is because python turns off SIGPIPE (sets
|> it to SIG_IGN), and on some platforms the fork inherits this
|> setting.
|
| That means it must survive the exec as well as the fork...

Yes, thank you, that's what I meant.

| Sounds like a misfeature to me -- ignoring SIGPIPE is
| something you only want to do when you're making some
| other arrangement about handling broken pipes. It's
| not something you want to foist onto an unsuspecting
| program!

I agree.  It has been around for a while, appears in the
1.5.2 source.  It would be interesting to know why.  Just
guessing, SIGPIPE is in a way a solution to C's problem
with error handling - in the example we were looking at,
"yes" got into a pathological situation without SIGPIPE
because it evidently doesn't check the result of its output,
unfortunately common practice.  Python will always check,
so arguably it doesn't need SIGPIPE to put it out of its
misery.  Not sure that justifies messing with it, though.

	Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list