Trying not to miss any output from a PROCESS

LEMAITRE Guillaume <[email protected]>
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <[email protected]>
   Hi

Continuing my attemps with the PROCESS class, I achieved to modelize a 
problem I encounter. I need to call a PROCESS very often, so that's why 
I write something like this to show you.

First, a little bash script

--> "random.sh"
#!/bin/sh

echo ${RANDOM}
<--

quite simple, but I'm sure it will always return an integer

then, my test class :

-->
class TEST_PROCESS

creation
    entree
feature

    entree is
       local
          p : PROCESS
       do
          from
	 until
             false
	 loop
	    create p.execute( "./random.sh", void, true )

             p.output.read_line
             std_output.put_integer( p.output.last_string.to_integer )
             std_output.flush
          end
       end
end
<--

then, I compile it this way : compile -debug_check test_process

a.out usually crashes saying that p.output.last_string is not an 
integer. In fact, it is empty.

I tried to write a loop in order to append every output of the PROCESS 
in a string, and then convert this string to an integer ; it appears to 
be also empty from time to time :

-->
class TEST_PROCESS

creation
    entree
feature

    entree is
       local
          p : PROCESS
	 resultat : STRING
       do
          create resultat.make_empty

          from
	 until
             false
	 loop
             resultat.clear_count
	    create p.execute( "./random.sh", void, true )

             from
             until
                not p.output.is_connected
             loop
                from
                until
                   not p.output.is_connected
                      or else not p.output.can_read_line
                loop
                   p.output.read_line
                   resultat.append( p.output.last_string )
                end
             end
				
             std_output.put_integer( resultat.to_integer )
             std_output.flush
          end
       end
end
<--

Does anybody can explain me my mistake(s)/misunderstanding(s) ?

Thanks in advance
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.