Reputation: 13
What signal (SIGTERM
, SIGINT
, ...) does the JVM raise during an unhandled exception?
For example, the exception might be java.lang.NumberFormatException
.
Upvotes: 1
Views: 636
Reputation: 462
Unhandled exceptions don't necessarily cause the JVM to raise a signal - it isn't necessary: the exception is caught by the Java system code and handled there (prints a stack trace and exits for instance).
There may be cases in which JVMs raise a signal in order to invoke a signal handler to log further diagnostic information.
On the other hand, the Oracle JVM (for instance) does install signal handlers to catch some specific errors and convert them to exceptions - see here for more details.
EDIT to followup on the comments above, and based on the link to the source (though you don't show the script that calls the failing Java program AFAICT):
The traps you've installed cause the shell interpreter to install signal handlers in case it receives SIGINT/... They don't get invoked if a child process receives such a signal (a raise causes the process in question to receive the signal - to signal another process you need to use kill and friends).
So even if the JVM were to raise a signal, the shell would not get it.
What could be happening in your case is that bash is configured to exit on error (e.g. set -o errexit), and so the lock release code does not get executed simply because the JVM's exit code is non null due to the unhandled exception.
To fix this, add ERR (and maybe EXIT) to the signal_spec of your trap call.
Upvotes: 2