Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to write a small server that behaves well when killed from the command line using its PID (i.e. not with CTRL-C). Installing signal handlers works well as long as I use the key-stroke to kill it but if I use the kill shell command no handling code gets called---both the signal handlers and END{} block are ignored (otherwise they get executed). I can't seem to figure out this problem and all my searching has been in vain (maybe I am searching for the wrong thing). Can anyone help out here? People have suggested I am catching the wrong signal but I have handlers installed for all applicable signals AFAIK.

I am not posting sample code since my signal handlers and end block are as simple as they come. This is not a question on how to use them, just a question on why the kill from the shell-command is being ignored by the perl code.

Thanks!

Replies are listed 'Best First'.
Re: signal handler not called
by VSarkiss (Monsignor) on Aug 29, 2001 at 22:20 UTC

    Two suggestions:

    1. Even if you don't post the code, post the list of signals you're trying to catch. It's more than likely that's where your problem lies.
    2. Try hitting your program with different signals from the shell (e.g., kill -USR1) and see if it responds to any of them. If it doesn't, the problem is likely to be in some other part of the program.

    HTH

Re: signal handler not called
by dga (Hermit) on Aug 29, 2001 at 22:14 UTC

    If you are typing kill PID from the shell, your perl script is recieving $SIG{TERM} so if you are catching that you should be ok.

Re: signal handler not called
by Zaxo (Archbishop) on Aug 29, 2001 at 22:21 UTC

    Please post the code anyway. Signal handling is close to the metal, so it would also be helpful to know OS, perl version, and what modules you use.

    It is difficult to help with no information

    After Compline,
    Zaxo

Re: signal handler not called
by Anonymous Monk on Aug 29, 2001 at 22:36 UTC

    ARG. SIGTERM was not being caught. I am a moron. I figured it out seconds after posting my question. Sorry if I wasted anyone's time.