Killing a shell script

Lenny Tropiano lenny at icus.islp.ny.us
Sat Feb 3 00:22:44 AEST 1990


In article <1990Feb1.171348.19968 at stb.uucp> michael at 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 at 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 -------+



More information about the Unix-pc.general mailing list