[plt-scheme] external processes

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Mar 28 07:55:32 EST 2006

At Tue, 28 Mar 2006 14:02:20 +0200 (CEST), Ivanyi Peter wrote:
>   - Did I miss something and it is possible to wait for a
> process that 
>     I have started by one of the four "process" functions?

Yes: the fifth result of `process' is a control function that you can
pass 'wait; the call will return only when the subprocess has finished.

> - For some reason, and I do not understand why, after the
> executed process is finished I cannot close its input port
> immediately, for
> example by the finaliser function. DrScheme will report that a 
> read-char  function tries to read from an already closed port. 
> Now who is reading from that port after the process has
> finished?

Do you supply the port to `process', or does `process' create the port?

If you supply the port and it's not a file-stream port, then `process'
creates a thread to copy between your port to the file-stream port
connected to the subprocess.

When you pass 'wait to the control function, then it returns only after
the port-managing thread has finished.

But I see that 'status to the control function reports that the
subprocess has finished even when the port-managing thread is still
running. Maybe this is what you're seeing? I'll fix 'status so that it
checks on the thread, and reports completion only when the thread is
also finished. (Meanwhile, it sounds like you want to use 'wait,
anyway.)

Matthew



Posted on the users mailing list.