Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Reading from a Named Pipe

by ikegami (Pope)
on Sep 28, 2006 at 03:21 UTC ( #575285=note: print w/replies, xml ) Need Help??

in reply to Reading from a Named Pipe

alarm will interrupt a read.

Replies are listed 'Best First'.
Re^2: Reading from a Named Pipe
by nzgrover (Scribe) on Sep 28, 2006 at 21:28 UTC
    ah ha! So something like:
    if (-p $named_pipe_name) { eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm $timeout; if (sysopen(FIFO, $named_pipe_name, O_RDONLY)) { while(my $this_line = <FIFO>) { chomp($this_line); $result .= $this_line; } close(FIFO); } else { $errormsg = "ERROR: Failed to open named pipe $named_pipe_name + for reading: $!"; } alarm 0; }; if ($@) { if ($@ eq "alarm\n") { # timed out $errormsg = "Timed out reading from named pipe $named_pipe_nam +e"; } else { $errormsg = "Error reading from named pipe: $!"; } } else { # didn't time out print STDOUT "$result\n"; } }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://575285]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2021-10-16 15:24 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (69 votes). Check out past polls.