guile-devel
[Top][All Lists]
Advanced

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

Re: Subprocess API.


From: Mathieu Othacehe
Subject: Re: Subprocess API.
Date: Mon, 25 Sep 2017 19:14:22 +0200
User-agent: mu4e 0.9.18; emacs 25.2.1

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 via email to

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