Re: pipe buffering



ptroyev wrote:
child's stdout is directed to write-end of pipe, output is read from read-end of pipe (in caller),
the problem is with buffering, is there a way to disable buffering on pipe?

Do you have access to the source code of "child"?

when child's output slows to 1-2chars /sec (progress indicator- "... ok") the read-end
of pipe is empty, it waits until buffer fills up and then gives the whole string.
seems that CreatePipe ignores its buffer-size parameter if set to 1,
tried to use ofs_handle + setbuf/setvbuf and also created the pipe with CreateFile with
FILE_FLAG_NO_BUFFERING, but nothing really changed


maybe it's because not tty handle is line-buffered by default

When you say stdout, do you mean the FILE* stdout? That's buffered, so are you using fflush in the child process? There are two layers of buffering here - CRT buffering of stdout and Windows buffering of the pipe. I think the child needs to use fflush for the first and FlushFileBuffers for the second.


Tom
.



Relevant Pages

  • Re: Design help...an explosion of interfaces......
    ... pipe is buffered are not; it is just loading or extracting from the pipe ... and call the right method with the right Pipe subclass instance. ... who understands the buffering context instantiate the relationship and ... the type attribute has a different semantics than the class ...
    (comp.object)
  • pipe buffering
    ... child's stdout is directed to write-end of pipe, ... read-end of pipe, ... the problem is with buffering, is there a way to disable buffering on pipe? ... seems that CreatePipe ignores its buffer-size parameter if set to 1, ...
    (microsoft.public.vc.language)
  • Re: stdout redirected to a processs own stdin
    ... Probably does not put anything in the pipe because output is buffered. ... > I suspect this is due to a misunderstanding of how pipes work. ... The UNIX system has no way of knowing about any ... turn off the output buffering with setbuf or flush the ...
    (comp.unix.programmer)
  • SUMMARY: Tru64 pipe buffer size
    ... The problem was that the application detected whether its stdout was going to file (pipe) or term, and did buffering in the case of a file. ... there was an easier way around the problem in our particular situation: Pipe the output via the tee command. ... Subject: Tru64 pipe buffer size ... We have a third-party tool which writes line-by-line to terminal device, but when its output is piped it seems to be buffering the data in chunks of approx 4KB at a guess. ...
    (Tru64-UNIX-Managers)
  • Re: fwrite over a pipe
    ... fprint or fwrite to output to the parent-to-child command pipeline, ... it might not be on the actual pipe when you do a read of the child." ... The fwrite and fprintf functions use buffered I/O. ... The buffering of these functions can be modified (or even turned ...
    (comp.unix.programmer)