Do all the redirection in the shell script and do not launch it in the background. The open(my $fh, "... |") will launch the script and also make it available for reading.
As an alternative, just write the process id to a file and then exec the Java process from the shell script. If you use exec, the PID will remain the same. Then read that pid from Perl and kill that other process.
In reply to Re^3: how to kill background process when script exit?
by Corion
in thread how to kill background process when script exit?
by Allasso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |