From: Marco B. <em...@be...> - 2002-08-31 19:34:42
|
brief introduction to the new function POSIX:EXEC (bad name but that's ok for now) - spawns sub process (fork/execve). takes 5 arguments: - name of file to run, a string. - list of arguments to pass, a list of strings. - whether to wait for sub process to terminate or not - file descritors to stream mapping. a list specifying which file descrptor (a number) to attach to which stream. the stream can be an already opened stream, or a list containg :DIRECTION, :BUFFERED, :ELEMENT-TYPE and :EXTERNAL-FORMAT keyword args with same semantics as OPEN. - enviroment to pass to sub process, a hash table with variable names as keys and values as strings. (once this works i'll add ability to specify enviroment as an alist, a plist, or an array of char arrays). returns multiple values, the first is the sub process's return value (or NIL if we didn't wait for it to terminate). the remaing values are the streams specifed for the file desriptors. would it better to return a single list containing these things instead? it does not spawn a shell (unlike MAKE-PIPE-INPUT-STREAM and MAKE-PIPE-OUTPUT-STREAM) , this because i don't see any advantages to it and spawning /bin/bash (or /bin/tcsh) just so that the shell can then fork and execve seems like a waste (if i've missed something tell me). currently it allows a lot of control over the subproc at the expense of not being very user freindly, ie: the first argument is not automatically set to the file's name, $PATH is not searched in the case of non absolute file names. i plan on building a convenient program calling/chaing macro on top of this function. any thoughts/comments on the road i've taken so far? however, i've got a problem (surprised? :)): currently the only streams you can pass it (to attach to file descriptors) are streams attached to files because only thoses streams have an associated Handle. I want to be able to attach any stream, for example, attach a string-output stream to standard out. my current idea is to just read/write from/to the stream to/from the sub process, but i think this has some major dead lock problems. any ideas? i'm not offering a patch yet because a) i'd like to test some things a bit more and b) finish some things which aren't working (like this stream problem and setting up the sub proc's enviroment). -- -Marco Ring the bells that still can ring. Forget your perfect offering. There is a crack in everything. That's how the light gets in. -Leonard Cohen |