Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I've written a perl script to poll the task list on a Win32 server to see if the spooler service is still up. We have had problems with the spooler service crashing, we could rebuild the box, but we're planning on moving to another server anyways, so I whipped up this script to page me when the spooler service goes down. Anyways....

The script sleeps for 10 minutes after each query to the server. I wanted to respond more gracefully to Ctrl-C, so I decided to write up a sigint trap. To my frustration I noticed that it doesn't interrupt the sleep command. To test this concept I whipped up this;

#!/perl/bin/perl -w use strict; $SIG{'INT'} = 'cleanup'; while (1) { print "."; sleep 10; } sub cleanup {die "\nending\n";}
It doesn't interrupt the sleep 10 command. I looked up the docs on the sleep command, it is supposed to respond to signal interrupts like SIGALARM, but doesn't it respond to SIGINT? What would you recommend instead of the sleep command that would respond to a SIGINT and allow for a more graceful shutdown? Thanks.

update (broquaint): added formatting


In reply to sleep doesn't respond to sigint(2)? by RolandGunslinger

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found