-
-
Save skuro/daf0b5471aab2d8085b6f821fd01f33f to your computer and use it in GitHub Desktop.
Clojure asynchronous process
This file contains hidden or 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