[plt-scheme] subprocess and wait

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Feb 26 09:05:07 EST 2006

At Sun, 26 Feb 2006 10:38:42 +0000, "Paulo J. Matos" wrote:
> I've have created a program in PLT Scheme, whose main objective is to
> gather a bunch of other programs and run them accordingly a specified
> algorithm which depends on their output. To run them I create a
> subprocess and then right after I do a subprocess-wait.
> After waiting returns I'll parse the huge output in search for a specific 
> token.

The buffer between MzScheme and the subprocess's stdout has a limited
size. If you don't read anything from subprocess's stdout, then the
subprocess will eventually not be able to write any more data, so it
will pause. Is that the problem?

If so, you need to read all the data from the subprocess's stdout as
its running, or you need to redirect the subprocess's stdout to a port
that holds arbitrary amounts of data. For example, you might call
`make-pipe' (with no arguments or with #f for the `limit-k' argument),
and use the resulting output port for the subprocess's stdout; since
the pipe's buffer is not limited, it will catch all of the subprocess's
data, and you can read it later.

Matthew



Posted on the users mailing list.