my $result; my $named_pipe_name = '/path/to/pipe'; my $timeout = 5; #check to see if named pipe exists if (-p $named_pipe_name) { #fork in such a manner as to enable us to get out what the child # reads from the NP if (my $childpid = open(FROMCHILD, "-|")) { #parent #set up the a SIGCHLD handler that will read what the child has # written local $SIG{CHLD} = sub { $result .= ; }; #wait for our timeout sleep ($timeout); #kill the child (if it still exists) kill 'HUP', $childpid; } else { #child #Open for reading only. note using sysopen without create flag # to prevent creation of the named pipe as a normal file if (sysopen(FIFO, $named_pipe_name, O_RDONLY)) { my $return_string; #read from the name pipe till EOF while(my $this_line = ) { chomp($this_line); $return_string .= $this_line; } close(FIFO); #tell the parent what we read print STDOUT $return_string; } else { print STDOUT "ERROR: Reading $named_pipe_name: $!"; } #exit causes the SIGCHLD to be sent. exit; } } print STDOUT $result;