I hear in java 9 they did a lot of work updating the Process API. Is there now a cleaner way to send a signal to a Process
spawned by Java? The signals are used as a simple way to trigger actions in the process.
Before I had to use reflection to get a pid
and then use Runtime#exec
to send the kill
command. I assume you still need to use Runtime#exec
because 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());
signal may be OS dependant
Yes, windows does not have signals in the same sense posix OSes do.
but I'm curious if anyone knows a better way than this!
jnr-posix provides thin wrappers around libc, including kill.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With