unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Chris Vine <vine35792468@gmail.com>
To: guile-devel@gnu.org
Subject: Re: Subprocess API.
Date: Sat, 23 Sep 2017 15:19:37 +0100	[thread overview]
Message-ID: <20170923151937.5bb7d80e@bother.homenet> (raw)
In-Reply-To: <87a81llos5.fsf@gmail.com>

On Sat, 23 Sep 2017 11:58:34 +0200
Mathieu Othacehe <m.othacehe@gmail.com> 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	other threads:[~2017-09-23 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-23  9:58 Subprocess API Mathieu Othacehe
2017-09-23 14:19 ` Chris Vine [this message]
2017-09-25 17:14   ` Mathieu Othacehe
2017-09-25 18:59     ` Chris Vine
2017-09-25 20:34       ` Chris Vine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170923151937.5bb7d80e@bother.homenet \
    --to=vine35792468@gmail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).