Of course this isn't the correct approach. You've indicated several times that you know what the correct approach is. Fixing your suspend problems would probably be even better.

You are likely to have problems if a non-masked thread in your JVM receives the SIGINT instead. This can happen if you are using a shared JVM between processes. If you completely control the environment, this is avoidable.

This is a kludge. It works, but it's a kludge.

Now if you want to avoid Java altogether, you should look at CPAN.

Updated (OT): Here's the Java code you would need to have your apps handle a Ctrl-C gracefully:

class ExampleShutdownHook { public static void main(String[] args) { // Java code to install shutdown hook: MyShutdown MyShutdown sh = new MyShutdown(); Runtime.getRuntime().addShutdownHook(sh); // Do the Joone stuff // . // . // . } } // Example shutdown hook class class MyShutdown extends Thread { public void run() { System.out.println("MyShutdown hook called"); // Dump the shutdown file // . // . // . } }

The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. -- Cyrus H. Gordon

In reply to Re: Signal handling with (implicit) fork by idsfa
in thread Signal handling with (implicit) fork by polettix

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.