views:

163

answers:

1

Using Jakarta Commons Daemon is it possible to have my Java application perform an action (reload a configuration) when a SIGHUP signal is sent to the jsvc process? If not - what are my other options for reloading the configuration with this library - without stopping the process? I have looked at the documentation but didn't find it that clear on this issue.

Note: I do not require a cross-platform way of handling signals. I just want to know what Jakarta Commons Daemon offers in terms of configuration reloading when used with a UNIX based platform.

+1  A: 

Java doesn't have a cross-platform way to handle signals. Your best bet is to open a Socket and wait for some input on it. Use netcat or a small Java program to connect to the socket. Inside, accept the connection, reload and close the connection. You don't even need to send data back and forth.

[EDIT] There doesn't seem to be any support to handle signals in the C part of Jakarta Commons Daemon. See this article from IBM how to implement your own signal handler in a JNI library. It was written for Java 1.3 but is still valid for Java 5 and 6.

[EDIT2] If portability is not an issue, you can try the undocumented and unsupported class sun.misc.Signal. See this thread. Note that it's unsupported, undocumented, etc. and the API didn't change for the past five years.

Aaron Digulla
Hi, that wasn't my question. I don't require a cross platform way to handle signals. I am interested only in how this is achieved with Jakarta Commons Daemon.
teabot
I understand. My answer is: JCD doesn't help in your case and the Java VM doesn't offer any other options.
Aaron Digulla