Signal handling in Java
Chris Sherlock
chris.sherlock79 at gmail.com
Thu Jun 22 16:23:48 UTC 2017
As part of writing my book on LibreOffice internals, I’m trying to understand why we special case signalling for the JVM.
We seem to be concerned about wiping out the JVM signal handlers, but any JVM used after v1.4 has the -Xrs switch that allows for signal chaining (see http://docs.oracle.com/javase/7/docs/technotes/guides/vm/signal-chaining.html <http://docs.oracle.com/javase/7/docs/technotes/guides/vm/signal-chaining.html>).
According to the Java documentation:
> The signal-chaining facility offers the following:
>
> Support for pre-installed signal handlers when the HotSpot VM is created.
> Support for signal handler installation after the HotSpot VM is created, inside JNI code or from another native thread.
> Pre-installed signal handlers (A) are supported by means of saving existing signal handlers, for signals that are used by the VM, when the VM is first created. Later, when any of these signals are raised and found not to be targeted at the Java HotSpot VM, the pre-installed handlers are invoked. In other words, pre-installed handlers are "chained" behind the VM handlers for these signals.
>
> The signal-chaining facility also allows an application to link and load a shared library libjsig.so before libc/libthread/libpthread. This library ensures that calls such as signal(), sigset(), andsigaction() are intercepted so that they do not actually replace the Java HotSpot VM's signal handlers if the handlers conflict with those already installed by the Java HotSpot VM (B). Instead, these calls save the new signal handlers, or "chain" them behind the VM-installed handlers. Later, when any of these signals are raised and found not to be targeted at the Java HotSpot VM, the pre-installed handlers are invoked. libjsig.so is not needed if (B) is not required.
>
We seem to jump through all sorts of hoops to implement this functionality, but given the JVM already caters for this, why are we doing this?
The issue seems to be in regards to adding crash handling code.
Great to get some feedback on this. I’ve tried a few things, but I must be missing something crucial due to my own lack of experience. I thought I’d take this to the ML rather than constantly harass poor sberg :-)
My Gerrit attempts can be found here:
Attempt 1:
https://gerrit.libreoffice.org/#/c/38916/3 <https://gerrit.libreoffice.org/#/c/38916/3>
Last attempt:
https://gerrit.libreoffice.org/#/c/38916/ <https://gerrit.libreoffice.org/#/c/38916/>
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20170623/e0bbaaec/attachment.html>
More information about the LibreOffice
mailing list