in reply to Re: Controlling a Perl Daemon with Signals
in thread Controlling a Perl Daemon with Signals

Right - I'm not getting that behaviour.

I am sure I'm sending term (kill -TERM <pid>)

Another fact: When I do kill -TERM, instead of exiting, the program seems to freeze, except that memory usage climbs indefintely - so it must be in some time of endless loop!

  • Comment on Re^2: Controlling a Perl Daemon with Signals

Replies are listed 'Best First'.
Re^3: Controlling a Perl Daemon with Signals
by sk (Curate) on Aug 06, 2005 at 04:15 UTC
    I modified the code to handle TERM signal and sent TERM from command prompt. It caught correctly and gave me expected results.

    I am guessing this not a web-based prog, if so I am not well-versed to explain why you it is not working for you.

    Regarding the jch341277's reply on TERM signal, I am not sure whether it is applicable to your case. For example, If the program was entering the condition in the  while block, it should execute just one more time and quit as you do not modify  $exit_requested inside the while block. Other cases should terminate next time the while condition is evaluated

    Can you try the sample program which prints "hi" and see if the same problem occurs. If it does it is very strange as it works just fine for me and I don't see any mistakes in your code.

    However if the above sample code works but not your original code then you might have to check your  handle_request() sub.

    -SK

      sk - I agree, it depends on what handle_request actually does. I just figured that it doesn't deal with the interruption gracefully; mainly because on my first attempt to run the code my handle_request looked like this:

      sub handle_request { sleep 13; return 1; }
      Which looked like it was doing what the OP is having trouble with.