Skip to content

A Clojure core.async library for efficiently managing subprocesses I/O

License

Notifications You must be signed in to change notification settings

threatgrid/asynp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asynp

A Clojure core.async wrapper around the excellent NuProcess library by Brett Wooldridge for efficiently interacting with a potentially large number of subprocesses concurrently.

Installation

Add the following dependency to your project.clj file:

Current Version

Usage

The following is a roughly complete demonstration of features and usage:

(require '[asynp.core :refer [run-process wait-for-process shutdown-process
                              close-stdin-for-process  write-str-to-process
                              log-strings decode-chars]])
(let [process-dict (run-process ["/bin/cat"])]

  ;; set up readers for stderr and stdout
  (log-strings (decode-chars (:out process-dict)) \u0000)
  (log-strings (decode-chars (:err process-dict)) \newline)

  ;; write content
  (write-str-to-process process-dict "Hello world\u0000Partial write")
  (Thread/sleep 1000)
  (write-str-to-process process-dict "...completed\u0000")

  ;; close stdin
  (close-stdin-for-process process-dict)

  ;; wait for 5 seconds for the process to exit, then force a shutdown
  (println (str "Exit status: " (wait-for-process process-dict 5000)))
  (shutdown-process process-dict))

License

Copyright © 2014 ThreatGRID, Inc.

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A Clojure core.async library for efficiently managing subprocesses I/O

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published