Hi,
I'm trying to write a ksh script that traps certain signals (HUP,
INT, QUIT, TERM). For testing, I wrote the following script:
#!/bin/ksh
trap 'print Signal caught' HUP INT QUIT TERM
while :; do
print "Sleeping ..."
sleep 30
done
I ran the script and opened another terminal session and issued a 'kill'
command followed by the PID # of the above script (say 11980):
$ kill -INT 11980
The script above didn't seem to trap the sent signal immediately. But
instead, completes the sleep (30 seconds) and then acknowledge the signal
(by invoking the command specified after the "trap" built-in command).
I posted a question to IBM, but the AIX Support person was unable to
duplicate the situation. He indicated during his testing that the signal
was caught by the "trap" command immediately without waiting for the sleep
to expire when he sent a signal using 'kill' to the PID of the ksh script.
The script, however, did get interrupted immediately if I type Ctrl-C
on the same terminal session running the script -- but this won't help me.
Has anyone seen this problem? Any known solution?
Thanks ..
----------------------------------------------------------------------
Okki Tranggana |
tel: (408) 974-7323 | 1 Infinite Loop, MS:76-2TI
fax: (408) 974-1560 | Cupertino, CA 95014
--
----------------------------------------------------------------------
Okki Tranggana |
tel: (408) 974-7323 | 1 Infinite Loop, MS:76-2TI
fax: (408) 974-1560 | Cupertino, CA 95014