You've already forked linuxdeploy
mirror of
https://github.com/encounter/linuxdeploy.git
synced 2026-07-10 12:18:44 -07:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18f2d94241 |
@@ -134,54 +134,8 @@ namespace linuxdeploy {
|
|||||||
}
|
}
|
||||||
log << std::endl;
|
log << std::endl;
|
||||||
|
|
||||||
auto process = subprocess::Popen(args, subprocess::output{subprocess::PIPE}, subprocess::error{subprocess::PIPE});
|
auto process = subprocess::Popen(args, subprocess::output{stdout}, subprocess::error{stderr});
|
||||||
|
process.wait();
|
||||||
|
|
||||||
std::vector<pollfd> pfds(2);
|
|
||||||
auto* opfd = &pfds[0];
|
|
||||||
auto* epfd = &pfds[1];
|
|
||||||
|
|
||||||
opfd->fd = fileno(process.output());
|
|
||||||
opfd->events = POLLIN;
|
|
||||||
|
|
||||||
epfd->fd = fileno(process.error());
|
|
||||||
epfd->events = POLLIN;
|
|
||||||
|
|
||||||
auto printOutput = [&pfds, opfd, epfd, this, &process]() {
|
|
||||||
poll(pfds.data(), pfds.size(), -1);
|
|
||||||
|
|
||||||
if (opfd->revents & POLLIN) {
|
|
||||||
std::ostringstream oss;
|
|
||||||
|
|
||||||
std::vector<char> buf(4096);
|
|
||||||
auto* lineptr = buf.data();
|
|
||||||
auto n = buf.size();
|
|
||||||
|
|
||||||
while (getline(&lineptr, &n, process.output()) != -1) {
|
|
||||||
oss << "[" << d->name << "/stdout] " << buf.data();
|
|
||||||
}
|
|
||||||
linuxdeploy::core::log::ldLog() << oss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (epfd->revents & POLLIN) {
|
|
||||||
std::ostringstream oss;
|
|
||||||
|
|
||||||
std::vector<char> buf(4096);
|
|
||||||
auto* lineptr = buf.data();
|
|
||||||
auto n = buf.size();
|
|
||||||
|
|
||||||
while (getline(&lineptr, &n, process.error()) != -1) {
|
|
||||||
oss << "[" << d->name << "/stderr] " << buf.data();
|
|
||||||
}
|
|
||||||
linuxdeploy::core::log::ldLog() << oss.str();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
do {
|
|
||||||
printOutput();
|
|
||||||
} while (process.poll() < 0);
|
|
||||||
|
|
||||||
printOutput();
|
|
||||||
|
|
||||||
return process.retcode();
|
return process.retcode();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user