[gambit-list] Re: stop external filters: SOLVED

Thomas Hafner thomas at hafner.NL.EU.ORG
Sat Jun 11 16:07:25 EDT 2005


Thomas Hafner <hafner at sdf-eu.org> wrote/schrieb <20050602120503.06BBC6040F86 at faun.hafner.NL.EU.ORG>:

> How can that be done? By adding (close-port p) somewhere? How should
> the example look like, if /bin/head is replaced by /bin/cat, and the
> sending thread decides to terminate after having sent 10 lines. The
> output should be the same as from the original example, of course.

No longer help needed, because I've found a solution. After having
written the last part of data, the sending thread just calls
close-output-port rather than close-port:

  (define p (open-process (list path: "/bin/cat")))
  
  (define t
    (make-thread
     (lambda ()
       (display "a\nb\nc\n" p)
       (display "d\ne\nf\ng\nh\ni\nj\n" p)
       (close-output-port p)))) 
  
  (thread-start! t)
  
  (let loop ()
    (let ((line (read-line p)))
      (if (eof-object? line)
          line
          (begin
            (display "[")
            (display line)
            (display "]\n")
            (loop)))))

Regards
  Thomas



More information about the Gambit-list mailing list