Fork problem?

Thanks for the info. The problem is apparently that the two programs(read
and write)
launched by Ruby are communicating synchronously, i.e. write have to wait
until
read finish reading the current buffer before proceeding the next write,
thus
the execution time is the total of read and writing. In the shell example,
they are apparently communicating asynchronously so that execution time is
the longest
of read or write.

I did the following

system(“readProgram fifo &”}
system(" writeProgram fifo &")

which should have the same performonce as the shell way. But they are not.

So does it mean the Ruby way of doing “system” or “exec” or “fork”
is different than thos of C?

Thanks

-Ted

···

-----Original Message-----
From: Hugh Sasse Staff Elec Eng [mailto:hgs@dmu.ac.uk]
Sent: Tuesday, September 24, 2002 8:49 AM
To: ruby-talk@ruby-lang.org
Subject: Re: fork problem?

On Tue, 24 Sep 2002, Meng, Ted wrote:

Hi,

From Unix command line, I did this

mkfifo fifo
readProgram fifo &
writeProgram fifo

fifo acts as a named pipe between the read and write program.

in Ruby, I did the following

fork { exec readProgram fifo}
system writeProgram fifo

This worked but the performance is much slower than the Unix commandline.

So how is:

fork { exec readProgram fifo}
exec writeProgram fifo

in comparison?

Any idea?

Thanks

-Ted

    Hugh