Skip to content

Instantly share code, notes, and snippets.

@skuro
Forked from codification/proc.clj
Created August 24, 2016 07:57
Show Gist options
  • Save skuro/daf0b5471aab2d8085b6f821fd01f33f to your computer and use it in GitHub Desktop.
Save skuro/daf0b5471aab2d8085b6f821fd01f33f 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