Re: Trying not to miss any output from a PROCESS

Mike Meyer <[email protected]>
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <[email protected]>
In <OFD12EB947.123CC046-ONC1256FFF.003FD059-C1256FFF.00414304@mpsa.com>, [email protected] typed:
> Hello,
> 
> > Does anybody can explain me my mistake(s)/misunderstanding(s) ?
> 
> Yes. There are two things to consider.
> 
> 1- parallelism
> 
> Both processes work in parallel. It may be that the first read_line 
> returns nothing if the process did not have a chance to run yet.

That's really strange behavior. Typical behavior for read on a pipe is
to block until input is available, or an EOF occurs. While blocking
I/O isn't always what's wanted, it certainly solves this problem.

> Your loop should then look like:
> 
>         from
>                 p.output.read_line
>         until
>                 not p.output.is_connected
>         loop
>                 resultat.append(p.output.last_string)
>                 p.output.read_line
>         end

You mean the code to read data from a pipe is *different* than the
code to read data from a disk file? Yuch. That means I can't write
code that should work with either, which is something that command
line utilities *really* need to be able to do.

	<mike
-- 
Mike Meyer <[email protected]>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.