On 12/20/05, Ruben Rubio Rey <[EMAIL PROTECTED]> 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's
nothing writing then the reading process will be blocked. And as
you've just seen, the same happens if you open one for writing and
there's nothing reading it.

You can change that behaviour by specifying the O_NONBLOCK flag when
opening the pipe - if you're opening it for writing, the attempt will
fail immediately rather than waiting for something to read.

I don't know of a way to do that through fopen(), but you can probably
manage it using dio_open() if you *really* want to.

It might be better to rethink how your processes communicate?

  -robin

Reply via email to