home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!oakhill!stevet
- From: stevet@oakhill.sps.mot.com (Steve Turner)
- Newsgroups: comp.unix.shell
- Subject: signal traps in Bourne -- HELP!
- Message-ID: <1992Dec21.223804.5764@oakhill.sps.mot.com>
- Date: 21 Dec 92 22:38:04 GMT
- Organization: Motorola Inc., Austin, Texas
- Lines: 45
-
- Is there a good way to tell a signal service routine to know which signal
- invoked it? The script below shows how I'm approaching this, but
- surely there is a more elegant way... any suggestions? Please
- send email to me directly. I'll post a summary if there is interest.
-
- ----------------- script follows -------------
-
- #!/bin/sh
-
- sigtrap()
- {
- case $SIGNAL in
- 1) echo killed by SIGHUP ;;
- 2) echo killed by SIGINT ;;
- # etc
- esac
- }
-
- sigcatch1()
- {
- SIGNAL=1; sigtrap; exit $SIGNAL
- }
- sigcatch2()
- {
- SIGNAL=2; sigtrap; exit $SIGNAL
- }
-
- # etc for 32 signals
-
- trap sigcatch1 1
- trap sigcatch2 2
-
- # etc for 32 signals
-
- # then run the main program below...
- read WORD
-
- ----------------- end script -----------
-
- Happy Holidays,
- --
- Steve Turner Motorola, Inc.
- stevet@risc.sps.mot.com RISC Design Automation
- 512.891.8728 Austin, TX
-
-