summaryrefslogtreecommitdiff
path: root/ninja/src/subprocess-posix.cc
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-05-22 18:24:25 +0200
committerAndras Becsi <andras.becsi@digia.com>2014-06-04 16:32:40 +0200
commit4ce69f7403811819800e7c5ae1318b2647e778d1 (patch)
tree2ec3a98b5abef002670a0916354eb7e0abfe2aa2 /ninja/src/subprocess-posix.cc
parenta6dd70e0328d155d5df8d6df48afbab690b08fb6 (diff)
downloadqtwebengine-chromium-4ce69f7403811819800e7c5ae1318b2647e778d1.tar.gz
Update Chromium snapshot to stable version 33.0.1750.170
This is meant as a baseline commit hence it does not include the patches we need to apply for QtWebEngine. All patches should be rebased on top of this commit so we can get rid of the external patches directory. In future these baseline commits always have to include the exact Chromium version returned by version_resolver.py's currentVersion() in their first line, so that we can retrieve the patches on top to apply on the upstream repository. This also includes a ninja update. Change-Id: I60abeadb785a3b7d149c58b65ddb5a823fed3083 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'ninja/src/subprocess-posix.cc')
-rw-r--r--ninja/src/subprocess-posix.cc53
1 files changed, 31 insertions, 22 deletions
diff --git a/ninja/src/subprocess-posix.cc b/ninja/src/subprocess-posix.cc
index a9af756dca4..743e4066136 100644
--- a/ninja/src/subprocess-posix.cc
+++ b/ninja/src/subprocess-posix.cc
@@ -25,7 +25,8 @@
#include "util.h"
-Subprocess::Subprocess() : fd_(-1), pid_(-1) {
+Subprocess::Subprocess(bool use_console) : fd_(-1), pid_(-1),
+ use_console_(use_console) {
}
Subprocess::~Subprocess() {
if (fd_ >= 0)
@@ -58,29 +59,34 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) {
// Track which fd we use to report errors on.
int error_pipe = output_pipe[1];
do {
- if (setpgid(0, 0) < 0)
- break;
-
if (sigaction(SIGINT, &set->old_act_, 0) < 0)
break;
if (sigprocmask(SIG_SETMASK, &set->old_mask_, 0) < 0)
break;
- // Open /dev/null over stdin.
- int devnull = open("/dev/null", O_RDONLY);
- if (devnull < 0)
- break;
- if (dup2(devnull, 0) < 0)
- break;
- close(devnull);
-
- if (dup2(output_pipe[1], 1) < 0 ||
- dup2(output_pipe[1], 2) < 0)
- break;
-
- // Now can use stderr for errors.
- error_pipe = 2;
- close(output_pipe[1]);
+ if (!use_console_) {
+ // Put the child in its own process group, so ctrl-c won't reach it.
+ if (setpgid(0, 0) < 0)
+ break;
+
+ // Open /dev/null over stdin.
+ int devnull = open("/dev/null", O_RDONLY);
+ if (devnull < 0)
+ break;
+ if (dup2(devnull, 0) < 0)
+ break;
+ close(devnull);
+
+ if (dup2(output_pipe[1], 1) < 0 ||
+ dup2(output_pipe[1], 2) < 0)
+ break;
+
+ // Now can use stderr for errors.
+ error_pipe = 2;
+ close(output_pipe[1]);
+ }
+ // In the console case, output_pipe is still inherited by the child and
+ // closed when the subprocess finishes, which then notifies ninja.
execl("/bin/sh", "/bin/sh", "-c", command.c_str(), (char *) NULL);
} while (false);
@@ -168,8 +174,8 @@ SubprocessSet::~SubprocessSet() {
Fatal("sigprocmask: %s", strerror(errno));
}
-Subprocess *SubprocessSet::Add(const string& command) {
- Subprocess *subprocess = new Subprocess;
+Subprocess *SubprocessSet::Add(const string& command, bool use_console) {
+ Subprocess *subprocess = new Subprocess(use_console);
if (!subprocess->Start(this, command)) {
delete subprocess;
return 0;
@@ -279,7 +285,10 @@ Subprocess* SubprocessSet::NextFinished() {
void SubprocessSet::Clear() {
for (vector<Subprocess*>::iterator i = running_.begin();
i != running_.end(); ++i)
- kill(-(*i)->pid_, SIGINT);
+ // Since the foreground process is in our process group, it will receive a
+ // SIGINT at the same time as us.
+ if (!(*i)->use_console_)
+ kill(-(*i)->pid_, SIGINT);
for (vector<Subprocess*>::iterator i = running_.begin();
i != running_.end(); ++i)
delete *i;