chicken-users
[Top][All Lists]
Advanced

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

Re: Using a pipe in chicken 5


From: Mark Fisher
Subject: Re: Using a pipe in chicken 5
Date: Thu, 6 Aug 2020 12:58:13 +0100

On Thu, 6 Aug 2020 at 12:47, Peter Bex <peter@more-magic.net> wrote:
> 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))))

Thanks Peter, I'd just worked that out locally and was trying to work
out how to reply to the mailing list!

I took the original code from
http://pestilenz.org/~ckeen/blog/posts/callbacks.html which does use
out as the input, and it makes sense because it's communicating with
some C code to push data to the "in" and reads it on the "out" from
scheme.
I think maybe pipes used to be bidirectional.
Looking at the FDs on the file-system, the permissions are "r" on IN
fd and "w" on OUT fd.
I vaguely wonder if changing them both to be r/w would also fix the issue.

However, I'm happy to have it working, so thanks for your response!

Mark



reply via email to

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