From: Scott Rubin Date: 2004-08-26T06:50:44+09:00 Subject: Open Fifo for Writing Ok, this problem I'm having is a little bit strange. I have two seperate processes running as part of this application. One process is written in C and the other process is written in Ruby. To communicate between the two processes I have two fifos in the file system. One fifo sends ASCII strings in one direction, and the other fifo goes in the other direction. Now, the problem is that pipes need to be opened on the reading end first. So I have it coded like this. # open the incoming fifo infifo = File.open( "infifo", IO::NONBLOCK | IO::RDONLY ) # launch the C process pid = fork do exec( "cprocess" ) end # open the outfifo outfifo = File.open( "outfifo", "w" ) There is an obvious problem here. The problem is that at some point the cprocess opens the outfifo on the other end. And the ruby program cannot open the outfifo for writing before the cprocess opens it for reading. I tried to place the outfifo = File.open call inside a while outfifo == nil. But that didn't work either. Is there a way in ruby to detect when the outfifo has been opened for reading on the other end? One way I thought of was for the C process to send a message up the incoming fifo to the ruby process to tell it when the outfifo is ready for opening. But I just want to make sure there isn't an easier and slicker way to do it with ruby. -Scott