How about having two different subs for handling interrupts, one being the default (handled by the server process), and one which redefines the sub when you fork to the child.
The server process handler (to keep things short) sets a flag variable to indicate it should go into shutdown mode as soon as it can (next check point).
At the check point, it enters a pre-die routine that sig INTs the children, then polls them at intervals (I've had SIGCHLDs disappear 'cos they happened while the server was already servicing a SIGCHLD) to see how they're doing.
If they haven't been killed within a particular amount of time, perhaps try a nastier kill (SIGTERM), unless you really need to keep the return value at shutdown time.
Retry as needed, until final time out, at which point you abort even trying to kill the thing, as it's gone beyond all reasonable point of recovery. That last bit shouldn't happen, but it's better to shut down as much as you can cleanly, than have the whole thing hang.
I hope some of this helps...
Cheers,
Malk
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.