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


In reply to Re^3: Controlling a Perl Daemon with Signals by sk
in thread Controlling a Perl Daemon with Signals by eastcoastcoder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.