Close a Running Sub-Process
- From: "mumebuhi" <mumebuhi@xxxxxxxxx>
- Date: 30 Aug 2006 14:07:42 -0700
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
found.
The code is as the following:
# start code
my $fh = undef;
my $child_process = "ssh username@host tail --follow=name
file_to_be_tailed"
open $fh, $child_process || Carp::confess("can't open $child_process:
$!");
while (<$fh>) {
chomp;
if (/successful/) {
last;
}
}
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.
Buhi
.
- Follow-Ups:
- Re: Close a Running Sub-Process
- From: xhoster
- Re: Close a Running Sub-Process
- From: axel
- Re: Close a Running Sub-Process
- Prev by Date: Re: FAQ 6.22 How can I match strings with multibyte characters?
- Next by Date: Re: imagemagick very slow - is there anything better?
- Previous by thread: FAQ 6.19 What good is "\G" in a regular expression?
- Next by thread: Re: Close a Running Sub-Process
- Index(es):
Relevant Pages
|