Reputation: 30097
If I kill gracefully (without -9
) a script which is running another script, which is running java in turn, will java process receive kill signal by cascade?
Upvotes: 1
Views: 222
Reputation: 703
I have seen java not properly shutdown in this case, and become owned by init (pid 1). I have fixed this in the past by recording the pid of the java process after it has launched, and then sending a kill -15 in a signal handler inside the bash script.
jpid=
trap_intr()
{
[ ! -z "$jpid" ] && kill $jpid
}
trap trap_intr INT TERM
java -cp ... foo &
jpid=$!
wait
UPDATE: I forgot to put the java process in the background, and have the bash script wait on $!
Upvotes: 1