Signal handling in Java vs. Python

I want a java program running in IBM JVM on AIX to ignore SIGINT and SIGTERM.
After lots of googling, I found I can use undocumented sun classes to do it in pure Java.
On Sun JVM, it said "java -Xrs Main" will work too (with reduced signal).
Another alternative is I can write it on JNI/C level with sigaction() on AIX.
I am a bit of surpurised (maybe not) how clumsy and kludgey Java is on this matter.
In Python it has  finer control and a lot moreelegant, with strong roots in UNIX, i.e. on the server side.
It is not necessarily to use Python for so called "enterprise" server side language, but at least  people who designed the language and API tend to forget about what is working, what is not.  
Platform independence doesn’t mean not working well on neither platform. I doubt if J2EE (on UNIX, server side) can compete with .NET (on windows) and win the battle. .NET is far from perfect, but J2EE is even far from the 3,000 feet. It consists full of impractical ideas and designs, most of them just made developer’s life harder, such as entity beans.
Here is the working Java code to ignore SIGINT and SIGTERM.
import sun.misc.Signal;
import sun.misc.SignalHandler;
public class Main {
 public static void main(String [] args) {
   SignalHandler handler = new SignalHandler () {
        public void handle(Signal sig) {
            System.out.println(" howdy, some dude sent an sig: "+sig);
      Signal.handle(new Signal("INT"), handler);
      Signal.handle(new Signal("TERM"), handler);
   try {;
  catch ( ioe) {
This entry was posted in java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s