| Date: Thu, 31 Mar 2005 12:26:34 +0100 (IST)
| From: Éibhear Ó hAnluain <eibhear.geo at yahoo.com>
|
| I am looking at a ksh script which has the following command:
|
| trap "clean_up; report_error $ERR_CLOSE_DOWN; exit" 1 2 3 4 5 6 7 8 9 10 \
| 11 12 13 14 15
|
| where clean_up() and report_error() are ksh functions also defined in the
| script.
|
| Is there a way (e.g. an environment variable?) for me to determine what
| signal was trapped so that I can report it in report_error()?
as far as I can recall, No.
so do something like (there are many variations on this theme):
trap "clean_up; report_error $ERR_CLOSE_DOWN 1; exit" 1
trap "clean_up; report_error $ERR_CLOSE_DOWN 2; exit" 2
...
trap "clean_up; report_error $ERR_CLOSE_DOWN 15; exit" 15
b.t.w., signal 9 is nominally SIGKILL, which cannot be caught,
so `trap'ping it is pointless. also, note that the exit(2)
status will be the return value of `report_error', which may
not be what you intend?
cheers!
-blf-
--
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!