Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Possible PipedProcess copy/paste err?

(1/1)

Pecan:
I was looking at PipedProcess today and ran across this.

Is the double "= GetErrorStream();" a result of the copy/paste imp again?

Should one of them be GetOutputSteam(); or the like?


--- Code: ---void PipedProcess::ForfeitStreams()
{
    char buf[4096];
    if (IsErrorAvailable())
    {
        wxInputStream *in = GetErrorStream();
        while(in->Read(&buf, sizeof(buf)).LastRead())
            ;
    }
    if (IsInputAvailable())
    {
        wxInputStream *in = GetErrorStream();
        while(in->Read(&buf, sizeof(buf)).LastRead())
            ;
    }
}


--- End code ---

MortenMacFly:

--- Quote from: Pecan on February 02, 2008, 06:25:33 pm ---Is the double "= GetErrorStream();" a result of the copy/paste imp again?

--- End quote ---
I'd say so, yes! Hence I wonder why it is working anyways... is the cout/cerr stream possibly combined?!

thomas:
It works because only the error stream matters. But yes, it looks like a copy error.

MortenMacFly:

--- Quote from: thomas on February 02, 2008, 09:33:41 pm ---It works because only the error stream matters. But yes, it looks like a copy error.

--- End quote ---
So Lieven... seems it's best if you fix this? ;-)

thomas:
It really doesn't matter, even though it's wrong. But go ahead and fix it if you want :)
The HasInputStream branch won't be taken, since the stream is already closed. Only the error stream cannot be closed programmatically which is why it must be drained, else the program might hang if you kill a process that has more data in the error stream than will fit in the buffer. However, killing doesn't work under Windows anyway, and under Linux,  the buffer size should not be a problem.

Navigation

[0] Message Index

Go to full version