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