Sending a signal to a process with Java 9

I heard that in java 9 they worked a lot, updating the Process API. Is there a cleaner way to send a signal to Processgenerated by Java? Signals are used as an easy way to trigger actions in the process.

Before I had to use reflection to get pid, then use Runtime#execto send the command kill. I suppose you still need to use Runtime#execit because the signal may be OS dependent, but I'm curious if anyone knows a better way than this!

Process p = Runtime.getRuntime().exec(...);
...
Runtime.getRuntime().exec("kill -SIGUSR1 " + p.getPid());
+4
source share
1 answer

signal may be OS dependent

, , OS.

, - , !

jnr-posix libc, kill.

+2

Source: https://habr.com/ru/post/1670472/


All Articles