[plt-scheme] Determining the status of open files

From: Jaime Vargas (jev at mac.com)
Date: Thu Jul 6 23:24:23 EDT 2006

Hi I am trying to write an application that starts replicating files  
as they are being created by monitoring activity in a directory. I  
wrote the following code to test the possibility of reading data from  
a file that is open by another process.

(define (display-unless-eof line)
   (unless (eof-object? line)
     (display line)

(define (keep-reading file)
   (display-unless-eof (read-line file))
   (keep-reading file))

(define temp-thread (thread (lambda () (keep-reading (open-input-file  

(thread-suspend temp-thread)

The code above seems to do part of the job. What I need now is  
something to determine when the other process stop writing, so that I  
can kill the thread.

In openbsd there is a command fstat http://tinyurl.com/mxfv5 which I  
could wrap. But I was wondering if there is a way to this in a cross- 
platform manner, and in a more elegant way.

Any ideas are welcome.

-- Jaime 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20060706/566020c2/attachment.html>

Posted on the users mailing list.