in reply to Re^3: how to kill background process when script exit?
in thread how to kill background process when script exit?
robiticus
okay, here's another example, with no ampersand. In this case, the app is (apparently) running in the background, because my script continues (prints out "pid: 1234"). HOWEVER, I can't exit the script until I exit the java app.
#!/usr/bin/perl my($JAVA_CLASSPATH) = @ARGV; my $kid = open(my $fh, "java -classpath $JAVA_CLASSPATH TextEntry 2> / +dev/null |") or die "Couldn't launch 'launch_java.sh': $! / $?"; END { if ($kid) { kill 9 => $kid; # bang }; }; print "pid: $kid\n\npress return to exit script...\n\n"; <STDIN>;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: how to kill background process when script exit?
by roboticus (Chancellor) on Feb 19, 2011 at 23:44 UTC | |
|
Re^5: how to kill background process when script exit?
by Corion (Patriarch) on Feb 20, 2011 at 00:14 UTC | |
by Allasso (Monk) on Feb 20, 2011 at 01:07 UTC | |
by Corion (Patriarch) on Feb 20, 2011 at 08:15 UTC | |
by Allasso (Monk) on Feb 20, 2011 at 14:43 UTC | |
by Corion (Patriarch) on Feb 20, 2011 at 14:51 UTC | |
|