Re: Close a Running Sub-Process



xhoster@xxxxxxxxx wrote:
"mumebuhi" <mumebuhi@xxxxxxxxx> wrote:

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

You capture the pid of the running process (it is the return value of a
pipe open), and then you kill it just prior to the close.

my $pid=open my $fh, $cmd or die $!;
#....
kill 1,$pid;
close $fh;

Unfortunately, this seems to leave idle processes hanging around
on the remote server. They will go away if the file they are tailing
ever grows enough so that tail -f fills up the pipe buffer, but if that
never happens then they might never get cleaned up. Maybe the safest thing
to do is write a perl emulation of tail which runs on the remote server.
Then you have the termination criteria evaluated at the remove server
rather than the local one.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.



Relevant Pages