in reply to how to kill background process when script exit?
and this doesn't (hangs - can't exit script until java app is closed):#!/usr/bin/perl my $pid = open(my $fh, "java -classpath /Users/allasso/AWS/utility/too +ls_additional/SC_add/java TextEntry |") or die "Couldn't launch: $! / $?"; print "pid: $pid\n\ndoing stuff...\n\npress return to exit script...\n +\n"; <STDIN>; if ($pid) { kill 9 => $pid; # bang };
#!/usr/bin/perl my $pid = open(my $fh, "java -classpath /Users/allasso/AWS/utility/too +ls_additional/SC_add/java TextEntry |") or die "Couldn't launch: $! / $?"; END { if ($pid) { kill 9 => $pid; # bang }; }; print "pid: $pid\n\ndoing stuff...\n\npress return to exit script...\n +\n"; <STDIN>;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to kill background process when script exit?
by Corion (Patriarch) on Feb 21, 2011 at 15:24 UTC | |
by Allasso (Monk) on Feb 21, 2011 at 15:47 UTC | |
by Corion (Patriarch) on Feb 21, 2011 at 15:56 UTC |