In file process.cpp in function CProcess::RunProcess there is a
loop that calls ReadStdOut. ReadStdOut itself has a loop that
reads characters from stdout or stderr.
The problem is that the
buffer pointer gets reset if a partial read occurs (if it doesn't quite
reach a '\n' or goes past it).
I fixed it by moving the buffer and
pointer and placing them in the class description under private in
the CProcess class of process.h.
char
outBuff[1024];
char *chr;
I added these 2 lines just
before the loop:
*outBuff = '\0';
chr =
outBuff;
// Read error/output pipes.
for ( ; ;
){
Sleep(100L);
ReadStdOut(job,
Pipes.hErr[0],
CPN_FROMERRPIPE);
ReadStdOut(job,
Pipes.hOut[0], CPN_FROMOUTPIPE);
// Still
running ?
::GetExitCodeProcess(pi.hProcess,
&exitCode);
if (exitCode !=
STILL_ACTIVE)
break;
}
And
commented out/removed these lines in
CProcess::ReadStdOut:
// char
outBuff[1024];
// *outBuff = '\0';
// char *chr =
outBuff;
The buffer and pointer could also be in CJob if more
that one process was allowed to run at one time (not the case
now).
François
Logged In: NO
It's still no good, it fixes one problem but not the case where stderr might
put stuff in the buffer!
I wrote a Buffer class that fixes both
problems and adds an overflow check (it's not used, but it's
there).
I've also added conditioner code for the grep (find in files)
thingy. I'll send a context diff or something later, it's too big to post
here.
Thanks,
Franois