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
read finish reading the current buffer before proceeding the next write,
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?




-----Original Message-----
From: Hugh Sasse Staff Elec Eng []
Sent: Tuesday, September 24, 2002 8:49 AM
Subject: Re: fork problem?

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


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?