jvm与系统信号(1)

下面是singal部分列表(POSIX.1-1990):

SIGHUP 1 Terminal line hangup
SIGINT 2 Interrupt program
SIGQUIT 3 Quit program
SIGILL 4 Illegal instruction
SIGABRT 6 Abort
SIGFPE 8 Floating-point exception
SIGKILL 9 Kill program
SIGSEGV 11 Invalid memory reference
SIGPIPE 13 Write on a pipe with no one to read it
SIGALRM 14 Alarm clock
SIGTERM 15 Termination signal
SIGUSR1 30,10,16 User-defined signal 1
SIGUSR2 31,12,17 User-defined signal 2
SIGCHLD 20,17,18 Child stopped or terminated
SIGCONT 19,18,25 Continue if stopped
SIGSTOP 17,19,23 Stop process

其中有多个值的singal,它的含义是与硬件体系相关,参考这里:一般alpha和sparc架构用第一个值,x86,arm架构用中间值,mips架构用第三个值, – 表示相应架构的取值未知。

比如SIGUSR1这个信号,有30,10,16 三种值,在x86上会用第二个值,也就是10.

$ /bin/kill -L | xargs -n2 | grep USR1
10 USR1

后来在POSIX.1-2001有部分新增或修改:

SIGTRAP 5 Trace trap
SIGBUS 10,7,10 Bus error (bad memory access)
SIGSYS 12,31,12 Bad system call
SIGURG 16,23,21 Urgent condition on socket (4.2BSD)
SIGXCPU 24,24,30 CPU time limit exceeded (4.2BSD)

现在看一下jvm里对singal的处理,参考这里 (The mention “optional” means that the signal is not necessary when the -Xrs option is specified):

Signal Description
SIGSEGV, SIGBUS, SIGFPE,
SIGPIPE, SIGILL
Used in the implementation for implicit null check, and so forth.
SIGQUIT Thread dump support: To dump Java stack traces at the standard error stream. (Optional.)
SIGTERM, SIGINT, SIGHUP Used to support the shutdown hook mechanism ( java.lang.Runtime.addShutdownHook) when the VM is terminated abnormally. (Optional.)
SIGUSR1 Used in the implementation of the java.lang.Thread.interrupt method. (Configurable.) Not used starting with Solaris 10 OS. Reserved on Linux.
SIGUSR2 Used internally. (Configurable.) Not used starting with Solaris 10 OS.
SIGABRT The HotSpot VM does not handle this signal. Instead it calls the abort function after fatal error handling. If an application uses this signal then it should terminate the process to preserve the expected semantics.

发表评论

电子邮件地址不会被公开。 必填项已用*标注