(destroy-forcibly! proc-hdl)Destroy the process handle's process forcibly.
Destroy the process handle's process forcibly.
(launch cmd-line)(launch cmd-line
{:keys [stdout-hdlr stderr-hdlr print-cmd-line?]
:or {print-cmd-line? true}})Launch a proccess.
Returns {:keys [^java.lang.ProcessHandle proc-hdl wait-or-kill]}:
proc-hdl - java.lang.ProcessHandlewait-or-kill - function that has two arities:
Example:
ham-fisted.process> (launch "ls -al" {:print-cmd-line? false})
{:proc-hdl #object[java.lang.ProcessHandleImpl 0x7f8e8742 "31019"],
:wait-or-kill #function[ham-fisted.process/launch/wait-or-kill--65545]}
...
ham-fisted.process> (def result ((:wait-or-kill *1)))
#'ham-fisted.process/result
ham-fisted.process> (keys result)
(:out :err)
Launch a proccess.
* cmd-line string command line.
* stdout-hdrl, stderr-hdlr - transduce-style rf functions that receive each string read from stdout
and stderr respectively.
Returns `{:keys [^java.lang.ProcessHandle proc-hdl wait-or-kill]}`:
* `proc-hdl` - java.lang.ProcessHandle
* `wait-or-kill` - function that has two arities:
1. (proc) - kill the process returning any output as {:out :err}.
2. (proc time-ms timeout-symbol) - wait specified time for process to terminate returning either
the timeout symbol or {:out :err}.
Example:
```clojure
ham-fisted.process> (launch "ls -al" {:print-cmd-line? false})
{:proc-hdl #object[java.lang.ProcessHandleImpl 0x7f8e8742 "31019"],
:wait-or-kill #function[ham-fisted.process/launch/wait-or-kill--65545]}
...
ham-fisted.process> (def result ((:wait-or-kill *1)))
#'ham-fisted.process/result
ham-fisted.process> (keys result)
(:out :err)
```(launch-jvm cmd-name {:keys [xmx jvm-opts] :as args})Assumes a jvm process launched from a shell command. Will hang looking for first process descendant.
If shell command then arguments other than :xmx :jvm-opts may need to have quoted strings if they are being passed the clojure process.
Example:
ham-fisted.process> (launch-jvm "clojure" {:jvm-opts ["-A:dev" "-X" "ham-fisted.protocol-perf/-main"]})
launch-process: clojure -A:dev -X ham-fisted.protocol-perf/-main
{:proc-hdl #object[java.lang.ProcessHandleImpl 0x4f4a8dc7 "31194"],
:wait-or-kill #function[ham-fisted.process/launch/wait-or-kill--10016],
:jvm-pid 31199,
:jvm-proc #object[java.lang.ProcessHandleImpl 0x2e52e7c8 "31199"]}
...
ham-fisted.process> (def result ((:wait-or-kill *1)))
#'ham-fisted.process/result
Assumes a jvm process launched from a shell command. Will hang looking for first process descendant.
If shell command then arguments other than :xmx :jvm-opts may need to have quoted strings if they are
being passed the clojure process.
Example:
```clojure
ham-fisted.process> (launch-jvm "clojure" {:jvm-opts ["-A:dev" "-X" "ham-fisted.protocol-perf/-main"]})
launch-process: clojure -A:dev -X ham-fisted.protocol-perf/-main
{:proc-hdl #object[java.lang.ProcessHandleImpl 0x4f4a8dc7 "31194"],
:wait-or-kill #function[ham-fisted.process/launch/wait-or-kill--10016],
:jvm-pid 31199,
:jvm-proc #object[java.lang.ProcessHandleImpl 0x2e52e7c8 "31199"]}
...
ham-fisted.process> (def result ((:wait-or-kill *1)))
#'ham-fisted.process/result
```Print process output using println. Example process output handler. Returns total output as a string to when finalized.
Print process output using println. Example process output handler. Returns total output as a string to when finalized.
(process-descendants proc-hdl)Get the first descendants of a process handle.
Get the first descendants of a process handle.
Record all the strings and save them to a vector
Record all the strings and save them to a vector
(stream->strings input)(stream->strings input bufsize charset)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |