tags:

views:

144

answers:

1

I have a shell script I wrote which does the following steps within a finite loop:

I spawn a process, and wait for it to finish. If it does not finish within 40 seconds, I execute:

kill -SIGTERM pid

I have found sometimes, even by doing the kill -SIGTERM pid, the process doesn't respond to being killed. In this case, after an additional 40 seconds of waiting for it to kill itself, I then execute:

kill -9 pid

Most times this is sufficient, and I move on to the next iteration of these steps.

THE PROBLEM: Sometimes in doing the above set of steps, I end up having not only the process I intended to kill, killed, but also the shell running the script which executes the loop of these steps.

QUESTION: What causes this?

+1  A: 

Two possibilities:

1.) you're passing the PID of the shell or script instead of the child process

2.) your shell/script is simply exiting normally because with the child process dead there is nothing left to do.

SpliFF