Hi, I'm trying to simulate reading from a TTY that writes every two seconds. I want to do this with a pipe and two threads, one thread writes every N seconds, while the other reads any data available on the pipe.
Unfortunately, my code just hangs. After speaking with the fine people in #chicken, it seems that this may be a bug. We played with different calls to put the threads to sleep, and different functions to read data, but they all ended up freezing at some point. Here is the program: (use srfi-18) (use posix) (define (produce writer) (thread-start! (lambda () (print "producer started") (let loop ((i 0)) (display (conc "hello" i " ") writer) (flush-output writer) (thread-sleep! 1) (loop (+ i 1)))))) (define (consume reader) (thread-start! (lambda () (print "consumer started") (let loop () (print (read-line reader)) (loop))))) (define (stream-test in-fd out-fd) (let ((reader (open-input-file* in-fd)) (writer (open-output-file* out-fd))) (produce writer) (thread-join! (consume reader)))) (call-with-values create-pipe stream-test) Any help would be greatly appreciated. Thanks! -- Aaron Patterson http://tenderlovemaking.com/ _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users