Skip to content
Charles Oliver Nutter edited this page Apr 5, 2016 · 4 revisions

JRuby supports the same Signal API that CRuby does, but there will be differences due to how various JVMs use those signals internally. Signals that are captured by the JVM will generally not be available for JRuby programs.

In some cases, as with Hotspot (OpenJDK/OracleJDK) there may be ways to reduce JVM signal usage (e.g. the -Xrs flag for Hotspot).

Details about how Hotspot uses signals can be found here: http://www.oracle.com/technetwork/java/javase/signals-139944.html#gbzbl

Details for IBM's J9 JVM are here: https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.zos.80.doc/user/signals.html

A quick summary of interesting signals:

  • Hotspot is known to use SEGV and related signals to optimize null checks, among other things.
  • Hotspot may use USR1 and USR2 on some platforms.
  • Hotspot connects INT to a JVM-wide hard shutdown. If you wish to capture this signal, you must trap it yourself; unlike CRuby, JRuby will not automatically bind it to an Interrupt-raising handler.
  • Most JVMs connect QUIT to a dump of thread and basic heap information. If you wish to handle it, trap it yourself (but you will lose the built-in dump ability).
  • Unusual platform-specific signals may not be mapped into JRuby, due to the fact that we have no per-platform compile phase.

If you need to use a platform-specific or JVM-occupied signal, try the -Xrs flag. If this does not make the signal available, contact the JRuby team via a Github issue or other community medium.

Clone this wiki locally