Re: Close a Running Sub-Process
- From: axel@xxxxxxxxxxxxxxxxxxxxxx
- Date: Wed, 30 Aug 2006 21:33:16 GMT
mumebuhi <mumebuhi@xxxxxxxxx> wrote:
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:
It is not valid Perl code for a start.
use warnings;
use strict;
Would have should you that. Actually it will not compile anyway.
# start code
my $fh = undef;
my $child_process = "ssh username@host tail --follow=name
file_to_be_tailed"
No ; at end of statement.
open $fh, $child_process || Carp::confess("can't open $child_process:
$!");
The format of $child_process shows that you are trying to open a file
for reading, nothing more... and the || has a high prority so as long as
$child_process is true then the right-hand side will be ignored.
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?
Not sure what is going on... but I suggest you clean up your code
properly first.
Axel
.
- Follow-Ups:
- Re: Close a Running Sub-Process
- From: mumebuhi
- Re: Close a Running Sub-Process
- References:
- Close a Running Sub-Process
- From: mumebuhi
- Close a Running Sub-Process
- Prev by Date: Re: Threading - share
- Next by Date: Re: Close a Running Sub-Process
- Previous by thread: Close a Running Sub-Process
- Next by thread: Re: Close a Running Sub-Process
- Index(es):
Relevant Pages
|