out_index_(0),
err_index_(0),
out_file_(of),
- terminal_out_exists_(os::is_terminal(os::STDOUT)),
- terminal_err_exists_(os::is_terminal(os::STDERR)),
process_events_(false)
{
if (!out_file_.empty()) {
if (!process_)
return false;
- process_events = process_events;
+ process_events_ = process_events;
// Block GUI while waiting,
// relay on QProcess' wait functions
- if (!process_events) {
+ if (!process_events_) {
if (waitwhile == Starting)
return process_->waitForStarted(timeout);
if (waitwhile == Running)
SystemcallPrivate::~SystemcallPrivate()
{
- flush();
-
if (out_index_) {
out_data_[out_index_] = '\0';
out_index_ = 0;
- if (terminal_out_exists_)
- cout << out_data_;
+ cout << out_data_;
}
cout.flush();
if (err_index_) {
err_data_[err_index_] = '\0';
err_index_ = 0;
- if (terminal_err_exists_)
- cerr << err_data_;
+ cerr << err_data_;
}
cerr.flush();
}
-void SystemcallPrivate::flush()
-{
- if (process_) {
- // If the output has been redirected, we write it all at once.
- // Even if we are not running in a terminal, the output could go
- // to some log file, for example ~/.xsession-errors on *nix.
-
- QString data = QString::fromLocal8Bit(process_->readAllStandardOutput().data());
- ProgressInterface::instance()->appendMessage(data);
- if (!terminal_out_exists_ && out_file_.empty())
- cout << fromqstr(data);
-
- data = QString::fromLocal8Bit(process_->readAllStandardError().data());
- ProgressInterface::instance()->appendError(data);
- if (!terminal_err_exists_)
- cerr << fromqstr(data);
- }
-}
-
-
void SystemcallPrivate::stdOut()
{
if (process_) {
process_->setReadChannel(QProcess::StandardOutput);
while (process_->getChar(&c)) {
out_data_[out_index_++] = c;
- if (c == '\n' || out_index_ + 1 == max_buffer_size_) {
+ if (c == '\n' || out_index_ + 1 == buffer_size_) {
out_data_[out_index_] = '\0';
out_index_ = 0;
ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(out_data_));
- if (terminal_out_exists_)
- cout << out_data_;
+ cout << out_data_;
}
}
}
process_->setReadChannel(QProcess::StandardError);
while (process_->getChar(&c)) {
err_data_[err_index_++] = c;
- if (c == '\n' || err_index_ + 1 == max_buffer_size_) {
+ if (c == '\n' || err_index_ + 1 == buffer_size_) {
err_data_[err_index_] = '\0';
err_index_ = 0;
ProgressInterface::instance()->appendError(QString::fromLocal8Bit(err_data_));
- if (terminal_err_exists_)
- cerr << err_data_;
+ cerr << err_data_;
}
}
}