On 4/11/11 16:19 , Faré wrote:
On 11 April 2011 10:07, Alessio Stallaalessiostalla@gmail.com wrote:
On Mon, Apr 11, 2011 at 3:19 PM, Ville Voutilainen ville.voutilainen@gmail.com wrote:
Could you implement a variant of run-program? It might require some trickery to support both Unix and Windows, but it would be very useful, probably beyond just XCVB.
Seems something worth considering.
I can work on it. It should be rather easy using the JVM APIs. Faré, do you have an example of a good Lisp API for this feature?
I suppose you could copy the API from CCL or SBCL, both of which are reasonably complete, and IIUC, portably implemented on both Windows and Unix at least for CCL. CMUCL and SCL have something similar, too - for good historical reasons. If it makes sense, I'd like also a :directory argument, but that's relatively secondary.
The JVM has reasonably a reasonably complete abstraction in [ProcessBuilder][1] that would be a fairly easy starting point.
[1]: http://download.oracle.com/javase/6/docs/api/java/lang/ProcessBuilder.html
A couple questions after a quick glance through the SBCL documentation for RUN-PROGRAM:
1) How important is the PROCESS structure returned? We can copy that, but don't totally have mappings for all its possible contents (like CORE-DUMP).
2) Can we skip the PTY part? This certainly doesn't have an analog under Windows, and I'm not sure how we would implement "the subprocess is established under a PTY" anyways.
3) Is it ok if STATUS-HOOK is only invoked when the process exits? I can't think of any other meaning for the abstractions available under the PTY.
I don't know if it makes sense wrt the underlying JVM API, but another different approach would be to expose posix_spawn - except that its libc implementation seems somewhat broken, so obviously no one is using it too seriously. Libfixposix reimplements it and iolib uses it to build its create-process abstraction that I'm working on refining. I don't know how much sense this makes on Windows or on the JVM API, though. But if you're interested, you should discuss with me and/or Stelian as we're trying to settle on an API for IOLib.
In the current ABCL implementation, exposing something like posix_spawn is really not the direction we want to go, as there are many different types of JVMs out there, and I would be hard put to see how we could implement this without heavy dependencies on the underlying JVM.