Close a Running Sub-Process

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I have a problem closing a filehandle, which is a pipe to a forked
process. The forked process basically tails a log file in another
server. I need to stop the child process once a particular line is

The code is as the following:
# start code
my $fh = undef;
my $child_process = "ssh username@host tail --follow=name
open $fh, $child_process || Carp::confess("can't open $child_process:
while (<$fh>) {
  if (/successful/) {
close $fh;
# end code

The script will block when it tries to close the filehandle. How do I
force it to close while tail is still running?

Thank you very much.


Site Timeline