Handling unix signals in Android Handling unix signals in Android unix unix

Handling unix signals in Android


It seems this is not really possible. The best solution available would be to add a shut down hook and "gracefully" restart the application, as described here:

EDIT:

I needed this because (back then) I had JNI code on which I opened a FD and r/w to it. The FD was opened to a named socket (a Unix pipe), and when the remote side of the pipe (in my case a daemon, or Android C/service) closes the connection (or dies), your side will get a signal. This is not always nice. IMHO the best to handle this should be using a signal handler from good old plain-C code, and just swallow it (otherwise - you should notify the Java side of your app).

http://stackoverflow.com/questions/2541597/how-to-gracefully-handle-the-sigkill-signal-in-java