Restore default SIGPIPE handler before invoking ‘man’
Fixes NixOS/nixpkgs#3410.
This commit is contained in:
parent
45f9a91e18
commit
50dc1f5b71
4 changed files with 17 additions and 15 deletions
|
@ -244,9 +244,9 @@ static void initAndRun(int argc, char * * argv)
|
||||||
|
|
||||||
void showManPage(const string & name)
|
void showManPage(const string & name)
|
||||||
{
|
{
|
||||||
string cmd = "man " + name;
|
restoreSIGPIPE();
|
||||||
if (system(cmd.c_str()) != 0)
|
execlp("man", "man", name.c_str(), NULL);
|
||||||
throw Error(format("command `%1%' failed") % cmd);
|
throw SysError(format("command `man %1%' failed") % name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -413,18 +413,6 @@ 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;
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
if (sigaction(SIGPIPE, &act, &oact)) throw SysError("resetting SIGPIPE");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -927,6 +927,16 @@ void closeOnExec(int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void restoreSIGPIPE()
|
||||||
|
{
|
||||||
|
struct sigaction act, oact;
|
||||||
|
act.sa_handler = SIG_DFL;
|
||||||
|
act.sa_flags = 0;
|
||||||
|
sigemptyset(&act.sa_mask);
|
||||||
|
if (sigaction(SIGPIPE, &act, &oact)) throw SysError("resetting SIGPIPE");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -273,6 +273,10 @@ void closeMostFDs(const set<int> & exceptions);
|
||||||
/* Set the close-on-exec flag for the given file descriptor. */
|
/* Set the close-on-exec flag for the given file descriptor. */
|
||||||
void closeOnExec(int fd);
|
void closeOnExec(int fd);
|
||||||
|
|
||||||
|
/* Restore default handling of SIGPIPE, otherwise some programs will
|
||||||
|
randomly say "Broken pipe". */
|
||||||
|
void restoreSIGPIPE();
|
||||||
|
|
||||||
|
|
||||||
/* User interruption. */
|
/* User interruption. */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue