|Pathologically Eclectic Rubbish Lister|
Reading from a Named Pipeby nzgrover (Scribe)
|on Sep 28, 2006 at 03:19 UTC||Need Help??|
nzgrover has asked for the
wisdom of the Perl Monks concerning the following question:
I need to:
Create a named pipe with a unique named.
Write a command to a (different) known named pipe.
Listen for the response on my unique named pipe.
Destroy the unique named pipe.
I have no problems creating and destroying the named pipe, however I've never done anything with named pipes before and though I've read up on their usage I'm not sure I'm reading/writing to them in a "safe" manner. In particular, I'm aware that if there is no corresponding writer/reader of the pipe then the write/read operation will block indefinitely. So when reading/writing to the pipe, i need to have a timeout. I thought the best way to do this would be to spawn a child process and make the parent kill the child if it took to long.
The "Reading" code.
The above works but I not confident it is the best way of doing this or even that it will be robust in the real world. Any enlightenment much appreciated!