[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using a pipe in chicken 5
From: |
Peter Bex |
Subject: |
Re: Using a pipe in chicken 5 |
Date: |
Thu, 6 Aug 2020 13:47:43 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Thu, Aug 06, 2020 at 12:01:40PM +0100, Mark Fisher wrote:
> Hi Chicken Users,
>
> I'm a new user of chicken, and am using it to learn scheme.
Hello and welcome, Mark!
> I've got an issue with using pipes.
> >From various sources I've created the following example, but when run
> I get an exception.
>
> ;; example.scm
> (import (chicken process))
> (import (chicken file posix))
> (import srfi-18)
>
> (let-values ([(in out) (create-pipe)])
> (print " in: " in)
> (print "out: " out)
> (let ([p-out (open-input-file* out)])
> (thread-wait-for-i/o! out #:input)
> (let ([data (read p-out)])
> (print "data: " data))))
It looks like you swapped the meaning of in and out; you are trying to
open the "out" descriptor for reading by converting it to an input port.
Try this instead:
(import (chicken process))
(import (chicken file posix))
(import srfi-18)
(let-values ([(in out) (create-pipe)])
(print " in: " in)
(print "out: " out)
(let ([p-in (open-input-file* in)])
(thread-wait-for-i/o! in #:input)
(let ([data (read p-in)])
(print "data: " data))))
Cheers,
Peter
signature.asc
Description: PGP signature