Skip to content

Instantly share code, notes, and snippets.

@beetleman
Forked from codification/proc.clj
Created March 17, 2020 19:34
Show Gist options
  • Save beetleman/b71cf2cba1f84e8d482b22fc3374033d to your computer and use it in GitHub Desktop.
Save beetleman/b71cf2cba1f84e8d482b22fc3374033d to your computer and use it in GitHub Desktop.
Clojure asynchronous process
(ns proc
(:import [java.lang ProcessBuilder])
(:use [clojure.java.io :only [reader writer]]))
(defn spawn [& args]
(let [process (-> (ProcessBuilder. args)
(.start))]
{:out (-> process
(.getInputStream)
(reader))
:err (-> process
(.getErrorStream)
(reader))
:in (-> process
(.getOutputStream)
(writer))
:process process}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment