[plt-scheme] custodian + process/ports

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Jul 1 16:30:40 EDT 2008

On Jul  1, Tom Schouten wrote:
> On Tue, Jul 01, 2008 at 01:43:54PM -0600, Chongkai Zhu wrote:
> > As the doc says, 'process/ports executes a shell command asynchronously,  
> > which means is is not under the control of custodian. It seems that you  
> > need to use 'subprocess instead of 'process/ports to get subprocess  
> > value, and then use 'subprocess-kill to kill it.
> 'subprocess also executes asynchronously, which i thought to mean
> "doesn't wait until process termination to return".
> Using process/ports the custodian does seem to close the ports, it
> just doesn't collect the return value of the process producing a
> zombie. Your suggested method works, but what i don't understand is
> why the 'close method of the port created by 'make-output-port
> doesn't get called by 'custodian-shutdown-all.

My guess would be that the subprocess object gets released, but the
process is still alive, which leads to the zombie.  (The main problem
being that custodians manage memory & ports, but not processes.)

> Then another question: what is the difference between the process
> and subprocess procedures? (maybe the question is really: What's the
> difference between ordinary ports and file ports wrt. custodians?)

* `subprocess' is the builtin functionality, `process' is in a scheme

* `subprocess' returns multiple values, `process' returns a list (it's
  an interface that was taken from scsh, I think)

* `subprocess' requires "stream" ports for stdin/out/err, or #f that
  returns a pipe that you need to feed or consume; `process' abstracts
  all that for you and simply uses the current scheme ports (making up
  the pipes and feeding threads when needed)

* `subprocess' is the only function that does what it does; `process'
  has several relatives (like `process' itself that takes a command
  line, `process*' that takes the executable and args, `system' that
  just runs the command synchronously, etc).

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.