Liking cljdoc? Tell your friends :D

koine.process

Subprocesses, portable.

sh runs a command to completion; spawn keeps a long-lived child with piped stdin/stdout, which is what an MCP stdio transport needs and what sh cannot express.

Subprocesses, portable.

`sh` runs a command to completion; `spawn` keeps a long-lived child with piped
stdin/stdout, which is what an MCP stdio transport needs and what `sh` cannot
express.
raw docstring

alive?clj/s

(alive? child)

True while the child is running.

True while the child is running.
sourceraw docstring

close!clj/s

(close! child)

Close the child's stdin, wait for it to exit, and return the exit code.

Close the child's stdin, wait for it to exit, and return the exit code.
sourceraw docstring

read-line!clj/s

(read-line! child)

Block for one line from the child's stdout, WITHOUT the terminator. nil at EOF.

Block for one line from the child's stdout, WITHOUT the terminator.
nil at EOF.
sourceraw docstring

send-line!clj/s

(send-line! child s)

Write s + newline to the child's stdin and flush. Returns nil.

Write `s` + newline to the child's stdin and flush. Returns nil.
sourceraw docstring

shclj/s

(sh command)
(sh command {:keys [in dir env] :as opts})

Run command (a vector) to completion. Returns {:out :err :exit}. Never throws on a non-zero exit — that is a normal result. opts: :in (string on stdin) :dir :env

Run `command` (a vector) to completion. Returns {:out :err :exit}.
Never throws on a non-zero exit — that is a normal result.
opts: :in (string on stdin) :dir :env
sourceraw docstring

spawnclj/s

(spawn command)
(spawn command {:keys [dir env]})

Start command (a vector) as a LONG-LIVED child with piped stdin/stdout and return a child handle — a map of closures, see above. This is what a line-delimited JSON-RPC transport (MCP stdio) requires; sh cannot express it.

The child's STDERR is drained from the moment it starts — see the comment above; not draining it deadlocks the child once the pipe buffer fills. Read it with stderr-lines.

opts: :dir :env

Start `command` (a vector) as a LONG-LIVED child with piped stdin/stdout and
return a child handle — a map of closures, see above. This is what a
line-delimited JSON-RPC transport (MCP stdio) requires; `sh` cannot express it.

The child's STDERR is drained from the moment it starts — see the comment
above; not draining it deadlocks the child once the pipe buffer fills. Read it
with `stderr-lines`.

opts: :dir :env
sourceraw docstring

stderr-linesclj/s

(stderr-lines child)

The child's most recent stderr lines (up to 200), oldest first, as a vector.

Always available — stderr is drained from the moment the child starts, so this is a snapshot of a buffer that is being filled for you, not a read that could block. Returns [] when the child has written nothing.

The child's most recent stderr lines (up to 200), oldest first, as a vector.

Always available — stderr is drained from the moment the child starts, so this
is a snapshot of a buffer that is being filled for you, not a read that could
block. Returns [] when the child has written nothing.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close