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());