guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subprocess API.


From: Chris Vine
Subject: Re: Subprocess API.
Date: Sat, 23 Sep 2017 15:19:37 +0100

On Sat, 23 Sep 2017 11:58:34 +0200
Mathieu Othacehe <address@hidden> wrote:
> Hi,
> 
> I recently used "open-pipe*" to launch a process but was unable to
> read from stderr. This subject was already discussed on this ml
> here : 
> 
> https://lists.gnu.org/archive/html/guile-user/2015-04/msg00003.html
> 
> Racket seems to have procedures to provide stdout/stdin/stderr ports
> for a given subprocess[1].
> 
> Mark, you said this subject was on your TODO list, is there anything
> available or would it be possible to develop a racket like API ?

The run-concurrently+ procedure in guile-lib
( http://www.nongnu.org/guile-lib/doc/ref/os.process/ ) should do what
you want.  Construct a pipe with guile's POSIX 'pipe' procedure and pass
the write port to the run-concurrently+ procedure for file descriptor 2
(stderr) and then read from the read port.  Close the write port on the
reader side before reading so that when the sub-process ends, the read
will return with an eof-object.

This works exactly as you would expect from its POSIX equivalents and
has the advantage that you can read from the pipe as the sub-process is
proceeding rather than just collect at the end.

Having said that it would be nice to have this in more formalized form
in guile itself, say something along the lines of ocaml's
Unix.create_process function.

Cjros



reply via email to

[Prev in Thread] Current Thread [Next in Thread]