LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] ksh: What signal did trap trap?

[ILUG] ksh: What signal did trap trap?

Brian Foster blf at blf.utvinternet.co.uk
Thu Mar 31 15:40:54 IST 2005


  | 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



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell