diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/build.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 436cf4762d..a1c99cddd0 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -361,6 +361,15 @@ const char * * strings2CharPtrs(const Strings & ss) } +/* Restore default handling of SIGPIPE, otherwise some programs will + randomly say "Broken pipe". */ +static void restoreSIGPIPE() +{ + struct sigaction act, oact; + act.sa_handler = SIG_DFL; + act.sa_flags = 0; + if (sigaction(SIGPIPE, &act, &oact)) throw SysError("resetting SIGPIPE"); +} ////////////////////////////////////////////////////////////////////// @@ -514,6 +523,8 @@ static void runSetuidHelper(const string & command, args.push_back(arg.c_str()); args.push_back(0); + restoreSIGPIPE(); + execve(program.c_str(), (char * *) &args[0], 0); throw SysError(format("executing `%1%'") % program); } @@ -1878,6 +1889,8 @@ void DerivationGoal::startBuilder() args.push_back(i->c_str()); args.push_back(0); + restoreSIGPIPE(); + /* Execute the program. This should not return. */ execve(program.c_str(), (char * *) &args[0], (char * *) envArr); |