http://www.perlmonks.org?node_id=575298


in reply to Reading from a Named Pipe

One of the points about a named pipe is that you can use them just like an ordinary file. There are exceptions, like you can't mmap them or do a seek, but generally they are transparent.
I see that you are opening an anonymous pipe with my $childpid = open(FROMCHILD, "-|")). Forgive me if I have misunderstood your code, but I wonder if you are confusing anonymous pipes (indicated by the | symbol) and named pipes? Generally anonymous pipes are used for communication between related processes (parent-child, for example), and named pipes (on UNIX, also called FIFO's) for communication between unrelated processes.

Replies are listed 'Best First'.
Re^2: Reading from a Named Pipe
by revdiablo (Prior) on Sep 28, 2006 at 15:43 UTC
    I wonder if you are confusing anonymous pipes (indicated by the | symbol) and named pipes?

    I started to think the very same thing after I posted my reply. It seems likely that's what the OP meant. Another point to keep in mind, you can create anonymous pipes using the pipe function, too. You don't have to use Perl's forking-pipe open call (though, I admit, it is very convenient).

Re^2: Reading from a Named Pipe
by nzgrover (Scribe) on Sep 28, 2006 at 20:42 UTC
    The reason I've done the "open" with the anonymous pipe is to enable the parent to get output from the child.
    The crux here is that the read from the named pipe my $this_line = <FIFO> could potential block indefinitely. That is why it is nessary (AFAIK) to fork (create the child) and have a timeout which kills the child if it does not manage to read from the pipe.