KILL PID, intern should kill another PID.

Hi All,

In my project i have two process runs in the back end.
Once i start my project, and execute the command ps, i get below output:

PID TTY TIME CMD
9086 pts/1 0:00 ksh
9241 pts/1 0:02 java
9240 pts/1 0:00 shell_script_bg

java with 9241 PID is the main process which runs my whole application.
if i have to say in one word, java process has the whole control of my app.

shell_script_bg with 9241 PID is the shell script, which starts the java command.

If i kill the java PID with kill -9 9241 , which shuts my complete application. But if i kill shell_script_bg pid, it not making my application go down.

My requirement is if i kill one PID it should intern kill java PID as well.
what r the changes i need to make in my shell script or any where else.

This is an urgent requirement. plz help me.

Regards,
Ravi.

Try with SIGTERM:

kill <shell_script_pid>

(kill sends SIGTERM -15- by default)
Regards.

thanks grial,

i think i had not explained in a proper way.

PID TTY TIME CMD
9086 pts/1 0:00 ksh
9241 pts/1 0:02 java
9240 pts/1 0:00 shell_script_bg

i mean to say if i kill the PID 9240 which belong to shell_script_bg, this intern should kill java PID 9241.

i killed the process shell_script_bg using kill -9 9240, shell_script_bg is the shell script code,

now my question is what is the code change i have to make in shell script, so that if i kill it's process ID then that should kill some other process ID (java's)internally.

Hello,

You can have this small script and include that at the end of your shell script

ps > input_ps
var=`grep java input_ps|cut -d" " -f1`
kill -9 $var

See if this helps....

K Regards,
Aparna

It was clear the first time :slight_smile:

What I'm telling you is to use
"kill -15 <script_pid>"
instead of
"kill -9 <script_pid>".