Hello! -- Here's a how-to question for subprocess and threading experts. What's the right way to obtain an output stream for stdout from a subprocess, and read it lazily?
At the moment, there's the sh function, but this collects all the output from the stdout and stderr streams into arrays, and returns them wholesale when these end. This doesn't work well for processes which generate very long streams of data. One approach might be to modify sh to return the stdout stream, but I think that won't tend to work, because the stderr stream must still be collected (for most programs), and the process would also probably have to be stopped at the end somehow. Another approach might be to make a function which creates the Process object -- say, open-subprocess, which returns a map {:out <stdout> :in <stdin> :err <stderr>}. But something still must service both the output and error streams. (sh handles this by interleaving character reads from the stdout and stderr streams.) A companion function close-subprocess would shut things down, and return the result code. (Could a close "method" be made for this, which would work with with-open?) At this point I'm thinking of an open-subprocess which spawns some kind of thread which could read either or both streams into an array. Is there another possibility for doing this? What's the usual way to handle this situation, if any? Of course, I could use sh to pipe the stdout to a temporary file, but that seems a cop-out. Thanks in advance for any and all answers! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en