[unix-pc.general] Killing a shell script

michael@stb.uucp (Michael Gersten) (02/02/90)

Ok, how do you kill a ksh shell script on the unix-pc?

I try: kill %1   (job one is a shell script)
Nothing happens.
Kill -9 will work, but its a bit extreame. How do you get scripts
(as opposed to interactive shells) to pay attention to SIGTERM?

			Michael
-- 
		Michael
denwa!stb!michael anes.ucla.edu!stb!michael 
"The 80's: Ten years that came in a row."

lenny@icus.islp.ny.us (Lenny Tropiano) (02/02/90)

In article <1990Feb1.171348.19968@stb.uucp> michael@stb.uucp (Michael Gersten) 
writes:
|>Ok, how do you kill a ksh shell script on the unix-pc?
|>
|>I try: kill %1   (job one is a shell script)
|>Nothing happens.
|>Kill -9 will work, but its a bit extreame. How do you get scripts
|>(as opposed to interactive shells) to pay attention to SIGTERM?
|>

Use the "trap" shell command:

eg:

$ cat dummy.sh
trap "echo Boo ; exit 1" 15
while true
do
	:
done

$ dummy.sh &
[1]	24367
$ kill %1
Boo
[1]	+ Done			dummy.sh&

Note the number after the trap is the signal.  You can specify as many
signals as you like after the "commands"

This should help?!

-Lenny
-- 
| Lenny Tropiano            ICUS Software Systems      lenny@icus.islp.ny.us |
| {ames,pacbell,decuac,hombre,sbcs,attctc}!icus!lenny     attmail!icus!lenny |
+------- ICUS Software Systems -- PO Box 1;  Islip Terrace, NY  11752 -------+