It is better not to.
Signal (English: signal) is a form of limited interprocess communication in POSIX-compliant OS such as UNIX and Unix. A mechanism for transmitting the occurrence of asynchronous events between processes or threads.
For example, you can stop it with Ctrl + C
while the program is running,
At this time, SIGINT is sent to the OS, a kill command is issued, and it is stopped.
There is an API called sun.misc. {Signal, SignalHandler}. However, this API is not supported, and it is uncertain whether it will remain or disappear in Java 9. https://blogs.oracle.com/java/get-ready-jdk9 scared. very scary.
For the time being, I will use this in this summary.
There are signals that the VM is grasping, so I would like to avoid that. That's why.
http://www.ibm.com/support/knowledgecenter/ja/SSYKE2_7.0.0/com.ibm.java.zos.71.doc/user/sighand.html As written here, the main signals are quite used.
http://www.oracle.com/technetwork/java/javase/signals-139944.html Again, the main signal is quite used. (It feels like the JVM)
--It is safer not to detect the main signal (SIGINT or SIGTERM) --User definition (SIGUSR1 / SIGUSR2) is also used
I can't say that. (But)
http://d.hatena.ne.jp/Kazuhira/20150422/1429713440 As written here, it cannot be used after RTMIN. sad. Very sad.
After spending a whole day so far, I decided to take another method. Fortunately, it wasn't a requirement to "detect the signal", so it's quite likely to be another way. Please be careful if there is a ** requirement to "detect a signal" **.
Recommended Posts