[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
102/376: Restore default SIGPIPE handler before invoking ‘man’
From: |
Ludovic Courtès |
Subject: |
102/376: Restore default SIGPIPE handler before invoking ‘man’ |
Date: |
Wed, 28 Jan 2015 22:04:20 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 50dc1f5b71f7e0e4ba628904b9a47d9f9d875b3e
Author: Eelco Dolstra <address@hidden>
Date: Thu Jul 31 10:31:17 2014 +0200
Restore default SIGPIPE handler before invoking ‘man’
Fixes NixOS/nixpkgs#3410.
---
src/libmain/shared.cc | 6 +++---
src/libstore/build.cc | 12 ------------
src/libutil/util.cc | 10 ++++++++++
src/libutil/util.hh | 4 ++++
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 1426344..47c38e3 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -244,9 +244,9 @@ static void initAndRun(int argc, char * * argv)
void showManPage(const string & name)
{
- string cmd = "man " + name;
- if (system(cmd.c_str()) != 0)
- throw Error(format("command `%1%' failed") % cmd);
+ restoreSIGPIPE();
+ execlp("man", "man", name.c_str(), NULL);
+ throw SysError(format("command `man %1%' failed") % name.c_str());
}
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 4376a83..479bc4a 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -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");
-}
-
-
//////////////////////////////////////////////////////////////////////
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index aa9d99e..f762b79 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -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");
+}
+
+
//////////////////////////////////////////////////////////////////////
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index ad0d377..64250c5 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -273,6 +273,10 @@ void closeMostFDs(const set<int> & exceptions);
/* Set the close-on-exec flag for the given file descriptor. */
void closeOnExec(int fd);
+/* Restore default handling of SIGPIPE, otherwise some programs will
+ randomly say "Broken pipe". */
+void restoreSIGPIPE();
+
/* User interruption. */
- 93/376: nix-copy-closure: Implement --gzip via ssh's -C flag, (continued)
- 93/376: nix-copy-closure: Implement --gzip via ssh's -C flag, Ludovic Courtès, 2015/01/28
- 91/376: Remove obsolete SSH master connection code, Ludovic Courtès, 2015/01/28
- 100/376: Rename nixPath to __nixPath, Ludovic Courtès, 2015/01/28
- 95/376: Change the default for use-ssh-substituter to ‘true’, Ludovic Courtès, 2015/01/28
- 90/376: Implement nix-copy-closure --from via nix-store --serve, Ludovic Courtès, 2015/01/28
- 97/376: Remove outdated AUTHORS file, Ludovic Courtès, 2015/01/28
- 92/376: Fix NIX_SSHOPTS, Ludovic Courtès, 2015/01/28
- 103/376: Allow regular files as GC roots, Ludovic Courtès, 2015/01/28
- 94/376: nix-copy-closure: Drop --bzip2, --xz, --show-progress, Ludovic Courtès, 2015/01/28
- 84/376: Use pthread_cancel instead of a signal, Ludovic Courtès, 2015/01/28
- 102/376: Restore default SIGPIPE handler before invoking ‘man’,
Ludovic Courtès <=
- 98/376: nix-profile.sh: Set $SSL_CERT_FILE, Ludovic Courtès, 2015/01/28
- 96/376: nix-daemon: Pass on the user's $SSH_AUTH_SOCK to the SSH substituter, Ludovic Courtès, 2015/01/28
- 101/376: make clean: Remove Makefile.config, Ludovic Courtès, 2015/01/28
- 105/376: findRoots(): Prevent a call to lstat(), Ludovic Courtès, 2015/01/28
- 108/376: Remove ugly hack for detecting build environment setup errors, Ludovic Courtès, 2015/01/28
- 107/376: Call commonChildInit() before doing chroot init, Ludovic Courtès, 2015/01/28
- 104/376: Make readDirectory() return inode / file type, Ludovic Courtès, 2015/01/28
- 106/376: Eliminate redundant copy, Ludovic Courtès, 2015/01/28
- 110/376: Make chroot builds easier to set up, Ludovic Courtès, 2015/01/28
- 109/376: Speed up nix-shell, Ludovic Courtès, 2015/01/28