Re:How to read pipe without buffering ?
AFAICS you are using exactly the same structure as I do, and I can't see
what's wrong with your code.
j_be...@hotmail.com schrieb:
Quote
> Create a Process to Read The StdOut and
> one for StdErr (same process except for the pipe)
> like this
Guess with Process you mean a thread, don't you?
Quote
> > Repeat
> > FillChar(l_Buffer, SizeOf(l_Buffer), 0);
> > ReadFile(i_Pipe,l_Buffer[0],C_BufferSizeRead-
> 1,l_BytesRead,nil);
> > result := (l_BytesRead <> 0);
> > if Result then
> > o_Result := o_Result + l_Buffer;
> > Until (l_BytesRead < C_BufferSizeRead-1) or (not Result)
Here is the reader thread code I use, but IMHO there is no real
difference:
procedure TReaderThread.Execute;
begin
while ReadFile(FPipe, FBuffer^, BufSize, FBytesRead, nil)
and (FBytesRead > 0) do begin
Synchronize(DoCallback);
// fr W9x:
if Terminated and (FBytesRead < BufSize) then exit;
end;
end;
Quote
> Step 2 Execute a console application
> when a execute a [DIR.*.*] or a [cd ..] commands everything is OK
> BUT
> 1) I have create an application that write to the stdout every second
> the time
> and I receive not each message separately but all by 128 bytes
What do you mean with 'message' here? Returning from ReadFile? Insert a
Beep there to have a response.
Are you sure your test application works well?
Run cmd.exe without hiding and without redirecting StdIn. Focus the
window and type. Can you receive the echo?
Quote
> 2) When I try to execute Python I don't receive the welcome message
> of the interpreter
> neither other message except some error messages (StdErr)
I don't know Python, but does this really output to StdOut? Can you
redirect its output to a file?
-Michael