in reply to Automatically killing a child
See perlopentut for details, but note that piped-opens return the pid of the forked child.
#!/usr/bin/perl my $kid = open (HTML, "-|") or exec("tail","-f","testlog.txt"); print while <HTML>; kill 2, $kid;
You can use that to kill or wait or waitpid, but as tail -f file will never terminate* unless the file goes away, you will probably need to kill it.
That said, if the file never goes away, tail will never terminate, so your print while <HTML> will never get eof, so you will never exit that loop in order to try and use kill.
*those versions of tail I've used.
|
|---|