[gambit-list] I/O Question

Marc Feeley feeley at iro.umontreal.ca
Thu May 1 18:35:19 EDT 2008

On 1-May-08, at 5:50 PM, Francisco wrote:

> (define (with-string-stop str c)
>  (let
>      ((port (open-string str)))
>    (read-string-until-char port c)))

"open-string" creates an input-output-port, that is a port you can  
write to and read from.  Whatever you write to it becomes readable (in  
other words it is a FIFO).  So the system cannot tell when the stream  
is at "end-of-file" because in principle some thread might have a  
reference to the port and at some point in the future add something to  
the FIFO.  However, the scheduler sees that no other thread is  
runnable when the read-char is called on an empty FIFO, so it declares  
that there is a deadlock (no further progress is possible).

So change the open-string by open-input-string (which creates an input- 
(only)-port) and the end-of-file will be read by read-char as you  
expect it.


More information about the Gambit-list mailing list