unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mathieu Othacehe <m.othacehe@gmail.com>
To: Chris Vine <vine35792468@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: Subprocess API.
Date: Mon, 25 Sep 2017 19:14:22 +0200	[thread overview]
Message-ID: <874lrqlmz5.fsf@gmail.com> (raw)
In-Reply-To: <20170923151937.5bb7d80e@bother.homenet>


Hi Chris,

> 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.

Thank you ! Following your suggestion, I ended-up with :

--8<---------------cut here---------------start------------->8---
(let* ((err-pipe (pipe))
       (out-pipe (pipe))
       (read-out (car out-pipe))
       (write-out (cdr out-pipe))
       (read-err (car err-pipe))
       (write-err (cdr err-pipe))
       (pid (run-concurrently+
             (apply tail-call-program "...")
             (write-out 1)
             (write-err 2)))
       (ret (status:exit-val (cdr (waitpid pid)))))
  (close-port write-out)
  (close-port write-err)
  (let ((output (read-string read-out))
        (error (read-string read-err)))
    (close-port read-out)
    (close-port read-err)
    (case ret
      ((0) output)
      (else (raise ...)))))
--8<---------------cut here---------------end--------------->8---

which seems to work. However, run-concurrently+ uses "primitive-fork"
which is forbiden in a multi-thread context (sadly, mine).

Do you have any idea on how to overcome this ?

Thanks,

Mathieu



  reply	other threads:[~2017-09-25 17:14 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
2017-09-25 17:14   ` Mathieu Othacehe [this message]
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=874lrqlmz5.fsf@gmail.com \
    --to=m.othacehe@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=vine35792468@gmail.com \
    /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).