REALLY kludgy, but it works :-)...
#!/usr/bin/perl my($JAVA_CLASSPATH) = @ARGV; $java_command = "java -classpath $JAVA_CLASSPATH TextEntry"; system("$java_command 2> /dev/null &"); $kid = `ps aux | grep "$java_command" | grep -v 'grep'`; $kid =~ s@^.*?\s+([0-9]+).*@$1@s; END { if ($kid) { kill 9 => $kid; # bang }; }; print "pid is: $pid\n\npress return to exit..."; <STDIN>
I would really like to find a more elegant way however.
In reply to Re^2: how to kill background process when script exit?
by Allasso
in thread how to kill background process when script exit?
by Allasso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |