[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
337/376: Revert "Use posix_spawn to run the pager"
From: |
Ludovic Courtès |
Subject: |
337/376: Revert "Use posix_spawn to run the pager" |
Date: |
Wed, 28 Jan 2015 22:06:01 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit ad332e17189668d18aeeea2f61384f749d428d6a
Author: Eelco Dolstra <address@hidden>
Date: Wed Dec 10 13:48:50 2014 +0100
Revert "Use posix_spawn to run the pager"
This reverts commit d34d2b2bbf784c0bb420a50905af25e02c6e4989.
---
src/libmain/shared.cc | 38 ++++++++------------------------------
src/libutil/types.hh | 1 -
src/libutil/util.cc | 10 ++--------
3 files changed, 10 insertions(+), 39 deletions(-)
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index ef4ea37..1d50346 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -15,7 +15,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <signal.h>
-#include <spawn.h>
extern char * * environ;
@@ -308,35 +307,14 @@ RunPager::RunPager()
Pipe toPager;
toPager.create();
- // FIXME: should do this in the child environment.
- if (!getenv("LESS"))
- setenv("LESS", "FRSXMK", 1);
-
- /* Start the pager using posix_spawn. */
- pid_t pid_;
- const char * argv[] = { "sh", "-c", pager.c_str(), 0 };
-
- posix_spawn_file_actions_t fileActions;
- int err = posix_spawn_file_actions_init(&fileActions);
- if (err) throw SysError(err, "creating POSIX file actions");
- err = posix_spawn_file_actions_adddup2(&fileActions, toPager.readSide,
STDIN_FILENO);
- if (err) throw SysError(err, "adding to POSIX file actions");
-
- posix_spawnattr_t spawnAttrs;
- err = posix_spawnattr_init(&spawnAttrs);
- if (err) throw SysError(err, "creating POSIX spawn attrs");
-#ifdef POSIX_SPAWN_USEVFORK
- err = posix_spawnattr_setflags(&spawnAttrs, POSIX_SPAWN_USEVFORK);
- if (err) throw SysError(err, "setting POSIX spawn attr flag");
-#endif
-
- err = posix_spawn(&pid_, "/bin/sh", &fileActions, &spawnAttrs, (char *
const *) argv, environ);
-
- posix_spawn_file_actions_destroy(&fileActions);
- posix_spawnattr_destroy(&spawnAttrs);
-
- if (err) throw SysError(err, format("running ‘%1%’") % pager);
- pid = pid_;
+ pid = startProcess([&]() {
+ if (dup2(toPager.readSide, STDIN_FILENO) == -1)
+ throw SysError("dupping stdin");
+ if (!getenv("LESS"))
+ setenv("LESS", "FRSXMK", 1);
+ execl("/bin/sh", "sh", "-c", pager.c_str(), NULL);
+ throw SysError(format("executing ‘%1%’") % pager);
+ });
if (dup2(toPager.writeSide, STDOUT_FILENO) == -1)
throw SysError("dupping stdout");
diff --git a/src/libutil/types.hh b/src/libutil/types.hh
index 030996a..160884e 100644
--- a/src/libutil/types.hh
+++ b/src/libutil/types.hh
@@ -73,7 +73,6 @@ class SysError : public Error
public:
int errNo;
SysError(const FormatOrString & fs);
- SysError(int errNo, const FormatOrString & fs);
};
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 60be02c..305e470 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -45,14 +45,8 @@ BaseError & BaseError::addPrefix(const FormatOrString & fs)
SysError::SysError(const FormatOrString & fs)
- : SysError(errno, fs)
-{
-}
-
-
-SysError::SysError(int errNo, const FormatOrString & fs)
- : Error(format("%1%: %2%") % fs.s % strerror(errNo))
- , errNo(errNo)
+ : Error(format("%1%: %2%") % fs.s % strerror(errno))
+ , errNo(errno)
{
}
- 330/376: Doh, (continued)
- 330/376: Doh, Ludovic Courtès, 2015/01/28
- 327/376: Use https://cache.nixos.org instead of http://cache.nixos.org, Ludovic Courtès, 2015/01/28
- 331/376: Fix bad comment, Ludovic Courtès, 2015/01/28
- 320/376: Define ‘environ’, Ludovic Courtès, 2015/01/28
- 333/376: builtins.readFile: realise context associated with the path, Ludovic Courtès, 2015/01/28
- 332/376: Always use https to fetch the Nixpkgs channel, Ludovic Courtès, 2015/01/28
- 326/376: Link against perl.dll on Cygwin, Ludovic Courtès, 2015/01/28
- 324/376: Set custom compiler flags on Cygwin, Ludovic Courtès, 2015/01/28
- 325/376: Fix library handling on Cygwin, Ludovic Courtès, 2015/01/28
- 335/376: Don't use RPATH on Darwin, Ludovic Courtès, 2015/01/28
- 337/376: Revert "Use posix_spawn to run the pager",
Ludovic Courtès <=
- 334/376: Update signing.txt, Ludovic Courtès, 2015/01/28
- 336/376: Cruft, Ludovic Courtès, 2015/01/28
- 339/376: Include cacert in the binary tarball, Ludovic Courtès, 2015/01/28
- 340/376: Rename function, Ludovic Courtès, 2015/01/28
- 342/376: Don't do vfork in conjunction with setuid, Ludovic Courtès, 2015/01/28
- 341/376: Use vfork, Ludovic Courtès, 2015/01/28
- 345/376: allow custom docbook paths/URLs, use a working URL for docbook.rng, Ludovic Courtès, 2015/01/28
- 344/376: Urgh, Ludovic Courtès, 2015/01/28
- 343/376: Provide default pagers, Ludovic Courtès, 2015/01/28
- 346/376: Don't use ?=, Ludovic Courtès, 2015/01/28