in reply to shutdown gracefully - kill signal trap

You will do yourself a lot of good, by reading all the available documentation on signal handlers BEFORE you start to work with them. They can be dangerous and they can cause unexpected behaviour under the right circumstances. In short, do not do anymore than absolutely necessary in the signal handler (re: only set a previously defined/initialized variable.) The simpler the better. The level of danger varies from platform to platform. While I've never used POSIX signals I've heard they are safer.

Just my $.02, I could be wrong.

  • Comment on Re: shutdown gracefully - kill signal trap

Replies are listed 'Best First'.
Re^2: shutdown gracefully - kill signal trap
by tachyon (Chancellor) on Sep 24, 2004 at 16:58 UTC

    As you note signals in Perl are dangerous. I use them all the time and they do cause the occasional seg fault. I mostly use them for clean exit handling as in the above case where it is a hell of a lot better than just crunching a process with kill -9. Your worst case is a kill -9 and the best case is a controlled exit.

    cheers

    tachyon