Process KILL

Hi All,

i wrote a shell script in unix, which intern runs java code, which will process the text file for 2 minutes.

Senario : After 30 seconds of processing the file, sombody executed a command kill -9 <PID> which killed my process, i.e, my java code stop processing the file and my application got exit.

Issue : Now i am unable to know what happened to my application.
if someone kills my application, i want to log it into a log file saying <PID> GOT KILLED.

Can anybody help me with a piece of code, which i can put in the shell script after my java application starts, so that if my java application gets KILL, it can go into that condition:

Ex. : if (<PID> KILLED)
"<PID> GOT KILLED" > LOG.TXT

What can i put in the place of bold text in the above if statement.

Regards,
Ravi

Check the exit status of your program.
If it have been killed by kill -n, the exit status will be 128+n

program_execution
exit_status=$?
if [ $exit_status -gt 128 ]
then
   signal=`expr $exit_status - 128`
   echo "Killed with signal $signal"
fi

Jean-Pierre.

Excellent, i got it....

ThanQ aigles