x******o 发帖数: 31 | 1 let's say that i have one process running at backend
(it is a java program like start from command line by:
java -cp ... MyJava.class) and suppose this process id is 101.
now, i send the signal from command line (on unix):
kill -9 101
how can i let MyJava.class response to -9 signal?
I think that JVM will take -9 signal at first and there is no ways for
MyJava.class to response -9 signal in this case.
So is there any other way for java program (like MyJava.class) to response
signal?
Thanks. |
t****t 发帖数: 6806 | 2 you can never trap signal 9 (SIGKILL), even without java.
neither can you trap SIGSTOP.
【在 x******o 的大作中提到】 : let's say that i have one process running at backend : (it is a java program like start from command line by: : java -cp ... MyJava.class) and suppose this process id is 101. : now, i send the signal from command line (on unix): : kill -9 101 : how can i let MyJava.class response to -9 signal? : I think that JVM will take -9 signal at first and there is no ways for : MyJava.class to response -9 signal in this case. : So is there any other way for java program (like MyJava.class) to response : signal?
|
X****r 发帖数: 3557 | 3 Besides what thrust has said, since signal is a POSIX things while Java
is supposed to be platform-independent, by definition there should be no
standard way to handle signals in Java. A Google search should tell you
all these non-standard ways, e.g. sun.misc.SignalHandler , depends on
the Java VM you're using.
【在 x******o 的大作中提到】 : let's say that i have one process running at backend : (it is a java program like start from command line by: : java -cp ... MyJava.class) and suppose this process id is 101. : now, i send the signal from command line (on unix): : kill -9 101 : how can i let MyJava.class response to -9 signal? : I think that JVM will take -9 signal at first and there is no ways for : MyJava.class to response -9 signal in this case. : So is there any other way for java program (like MyJava.class) to response : signal?
|
r*********r 发帖数: 3195 | 4 windows 上难道没有这个东西?
搞得连 boost 都没有 signal handling 好像。 |
t****t 发帖数: 6806 | 5 windows好象没signal
cygwin是用一个单独的线程来等"信号"事件的(真TMD浪费) |