Created
March 6, 2012 08:10
-
-
Save codification/1984857 to your computer and use it in GitHub Desktop.
Clojure asynchronous process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
See also https://gist.github.com/gerritjvv/5866665