summaryrefslogtreecommitdiffstats
path: root/src/subprocess.cc
diff options
context:
space:
mode:
authorAmi Fischman <fischman@chromium.org>2012-03-04 03:58:09 (GMT)
committerAmi Fischman <fischman@chromium.org>2012-03-04 03:58:09 (GMT)
commitf6887638b7327f45ff8fa8a29420c48c059182c4 (patch)
tree4513041bf3dfc7cfc94840d690f65d8bb9b3f480 /src/subprocess.cc
parentcd2e3c9115bd2df3db0d11cfc38ab82a17fcac06 (diff)
downloadNinja-f6887638b7327f45ff8fa8a29420c48c059182c4.zip
Ninja-f6887638b7327f45ff8fa8a29420c48c059182c4.tar.gz
Ninja-f6887638b7327f45ff8fa8a29420c48c059182c4.tar.bz2
addressed pcc comments
Diffstat (limited to 'src/subprocess.cc')
-rw-r--r--src/subprocess.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/subprocess.cc b/src/subprocess.cc
index 3de574b..99de93f 100644
--- a/src/subprocess.cc
+++ b/src/subprocess.cc
@@ -42,12 +42,12 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) {
if (pipe(output_pipe) < 0)
Fatal("pipe: %s", strerror(errno));
fd_ = output_pipe[0];
-#if !defined(OS_LINUX)
+#if !defined(linux)
// On linux we use ppoll in DoWork(); elsewhere we use pselect and so must
// avoid overly-large FDs.
if (fd_ >= FD_SETSIZE)
Fatal("pipe: %s", strerror(EMFILE));
-#endif // !OS_LINUX
+#endif // !linux
SetCloseOnExec(fd_);
pid_ = fork();
@@ -182,10 +182,9 @@ Subprocess *SubprocessSet::Add(const string &command) {
return subprocess;
}
-#ifdef OS_LINUX
+#ifdef linux
bool SubprocessSet::DoWork() {
- struct pollfd* fds = new pollfd[running_.size()](); // XXX: scoped_array?
- memset(fds, 0, running_.size() * sizeof(struct pollfd));
+ vector<pollfd> fds;
nfds_t nfds = 0;
for (vector<Subprocess*>::iterator i = running_.begin();
@@ -193,12 +192,12 @@ bool SubprocessSet::DoWork() {
int fd = (*i)->fd_;
if (fd < 0)
continue;
- fds[nfds].fd = fd;
- fds[nfds].events = POLLIN | POLLPRI | POLLRDHUP;
+ pollfd pfd = { fd, POLLIN | POLLPRI | POLLRDHUP, 0 };
+ fds.push_back(pfd);
++nfds;
}
- int ret = ppoll(fds, nfds, NULL, &old_mask_);
+ int ret = ppoll(&fds.front(), nfds, NULL, &old_mask_);
if (ret == -1) {
if (errno != EINTR) {
perror("ninja: ppoll");
@@ -230,7 +229,7 @@ bool SubprocessSet::DoWork() {
return false;
}
-#else // OS_LINUX
+#else // linux
bool SubprocessSet::DoWork() {
fd_set set;
int nfds = 0;
@@ -273,7 +272,7 @@ bool SubprocessSet::DoWork() {
return false;
}
-#endif // OS_LINUX
+#endif // linux
Subprocess* SubprocessSet::NextFinished() {
if (finished_.empty())