Johan Hidding <johannes.hidd...@gmail.com> 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"