guile-user
[Top][All Lists]
Advanced

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

Re: getting pipes going


From: Ian Price
Subject: Re: getting pipes going
Date: Wed, 20 Jun 2012 20:57:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Johan Hidding <address@hidden> writes:

> Hi everyone,
> I'm having difficulties getting (open-pipe ...) to work for me. I
> would expect the following code:
>
> (use-modules (ice-9 popen))
>
> (display (with-output-to-string (lambda ()
>            (let ((P (open-pipe "cat" OPEN_WRITE)))
>              (display "Hello World!\n" P)
>              (close-pipe P)))))
>
> to output: Hello World!
> But it gives me nothing, using guile-2.0.5. What's going wrong? I
> would love to see some examples on how pipes are "supposed to be"
> used.

The documentation is clear on the fact that it expects the
current-*-ports to be backed by file descriptors (file ports or
sockets,etc). This is not the case for string ports. The design decision
is IMO unacceptable (it should either work transparently, or fail
loudly), but it is they way things are until someone who cares writes a
better module for this.

     If those `current-X-ports' are not files of some kind, and hence
     don't have file descriptors for the child, then `/dev/null' is
     used instead.

The easiest solution is probably to use OPEN_BOTH, and then read all the
output as a string using get-string-all from (rnrs io ports).

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



reply via email to

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