mike@e53.austin.ibm.com (Michael McClung) (06/25/91)
I'm having trouble defining a cleanup function in perl. In ksh I'd use
trap 'Cleanup' EXIT HUP INT QUIT TERM
I thought the equivalent in perl would be something like
%SIG = ('EXIT','cleanup','HUP','cleanup','INT','cleanup',
'QUIT','cleanup','TERM','cleanup');
But the perl didn't call cleanup on exit . I tried the following
simple test to see if any signals were being caught.
sub cleanup { print "In cleanup\n"; }
$SIG{'INT'} = 'cleanup';
kill 'INT', $$;
This did work. When I tried the same test with EXIT, the kill command
gave an error (Unrecognized signal name "EXIT"). IT also didn't work
when I used '0' in place of EXIT.
So anyway, I'm confused. What are the recognized signals in perl?
Can an EXIT signal be caught in perl? I'm aware of the eval approach
(page 138 in the camel book) of defining a cleanup routine but I thought
using a signal was cleaner. Help would be appreciated.tchrist@convex.COM (Tom Christiansen) (06/26/91)
See /usr/include/signal.h: there is no "exit" signal. Add a &cleanup call as the last executable line of your script. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."