Re: Write a FIFO file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/20/05, Ruben Rubio Rey <ruben@xxxxxxxxxxxx> wrote:> Robin Vickery wrote:>> >I bet your script will finish as soon as you read from the other end -> >for example by doing 'cat fifo' from a shell.> >> Thats it.> I would like to use fifo, but thats a problem. If there is not process> reading, it wont work.> Is there any way to create process?> Something like:>     exec("echo \"My text $var\" > fifo &"); //(This idea does not work)
Named pipes are blocking - if you open one for reading and there'snothing writing then the reading process will be blocked. And asyou've just seen, the same happens if you open one for writing andthere's nothing reading it.
You can change that behaviour by specifying the O_NONBLOCK flag whenopening the pipe - if you're opening it for writing, the attempt willfail immediately rather than waiting for something to read.
I don't know of a way to do that through fopen(), but you can probablymanage it using dio_open() if you *really* want to.
It might be better to rethink how your processes communicate?
  -robin

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux