On Fri, Jul 16, 2010 at 12:08:21PM +0200, Peter Kümmel wrote:
> Enrico Forestieri wrote:
> > On Fri, Jul 16, 2010 at 11:31:02AM +0200, Peter Kümmel wrote:
> >> Enrico Forestieri wrote:
> >>  >>>       ///
> >>>>> -       bool showerr_;
> >>>>> +       bool terminalOutExists_;
> >>>> terminal_out_exists_
> >>> stdout_exists_
> >> Hope attached patch makes the code more readable.
> > 
> > Yes, I think so, but see below.
> > 
> >> But why do we ignore the terminal settings in flush() ?
> > 
> > What do you mean?
> 
> 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 (!use_stdout_ && out_file_.empty())
>                       cout << fromqstr(data);
> 
> 
> 
> Does this mean if 'out_file_' is not empty cout is implicitly redirected to 
> out_file_ and
> we must write to cout to fill out_file_?
> 
> Where is the redirection from cout to out_file_ done?

On unix, even if you don't have a controlling terminal, the output is
always collected and sent to ~/.xsession-errors. This occurs for all
running programs. So, instead of scattering the output here and there,
in order to avoid mixing it with the output of other programs, we output
everything all at once. The check "if (!use_stdout_ && out_file_.empty())"
means "if we don't have a controlling terminal and output is not being
redirected, we send it to stdout anyway, in order to have it appended to
~/.xsession-errors". This is a complication brought in by QProcess, the
same as the need for having a pseudo parser for emulating the job (see
redirection, but also quoting) that would have been done by the shell.
We bypass the shell, so we have to do all the work.

-- 
Enrico

Reply via email to