When constructing a pipe to child stdin on Posix, ignore SIGPIPE.

We can't count on every child process reading everything we try to write to
it. And if the child terminates with WritePipe data still pending, unless we
explicitly suppress it, Posix will hit us with SIGPIPE. That would terminate
the calling process, boom. "Ignoring" it means APR gets the correct errno,
passes it back to us, we log it, etc.
master
Nat Goodspeed 2012-02-29 19:40:18 -05:00
parent 3649eda62a
commit 40dc3e0d3b
1 changed files with 9 additions and 0 deletions

View File

@ -145,6 +145,15 @@ public:
mConnection = LLEventPumps::instance().obtain("mainloop")
.listen(LLEventPump::inventName("WritePipe"),
boost::bind(&WritePipeImpl::tick, this, _1));
#if ! LL_WINDOWS
// We can't count on every child process reading everything we try to
// write to it. And if the child terminates with WritePipe data still
// pending, unless we explicitly suppress it, Posix will hit us with
// SIGPIPE. That would terminate the viewer, boom. "Ignoring" it means
// APR gets the correct errno, passes it back to us, we log it, etc.
signal(SIGPIPE, SIG_IGN);
#endif
}
virtual std::ostream& get_ostream() { return mStream; }