In Clojure, how do I send an exit command to a process created by Clojure.java.shell/sh
clojure.java.shell/sh
won't return until the process being executed completes and you would need to use another thread to use kill on a pid.
Another solution would be to use java.lang.Runtime.exec
or java.lang.ProcessBuilder
to get a java.lang.Process
instance which provides methods like destroy
or destroyForcibly
.
You can also use a Raynes/conch library if you still would like to have a nice Clojure API and still be able to run a command and specify a timeout for the process to complete and still get the output produces until the timeout occured.