From: Martin Cracauer
Subject: Re: 'hooking' into low level routines?
Date: 
Message-ID: <1997Jan18.172503.6520@wavehh.hanse.de>
·······@tcd.ie (domo baby) writes:

>I have a problem.  I have a function which constantly examines the
>contents of a file, and may or may not do something depending on the
>contents of the file.  This file can be changed by an application
>external to the lisp package.

>I want to be able to run this function regularly in the background, so
>to speak, have it automatically called at regular intervals - but
>without having to worry about it in my main lisp program.  As lisp is an
>interpreted language I am sure there are hooks, such as garbage
>collection or whatever, that I can hang this function off to achieve the
>desired effect. I haven't looked into this in any great detail at the
>moment, I have plenty of other stuff Im working on, but if anyone out
>there has any ideas I'd be most greatful to hear their thoughts.

Your request would have been more useful if you said what Lisp
implementation you are using. Obvious, isn't it? :-)

The cannonical Lisp implementation - in that case of the Scheme
dialect - to handle low-level things like timer signals is scsh - The
Scheme Shell. That would make the task easy.

In general, doing what you intend is not easy in a non-threaded Lisp
that is not prepared to be interrupt-save, which is the case for most
free systems.

But, you're not apporaching the best solution for your problem
anyway. If you want to monitor a file that might be changed by outside
programs, you really shouldn't do it by periodical polling. Use the
select system call instead (or poll on Sys V). If you're not on Unix
(it would have been useful to tell us your platform, too), there are
similar calls for Win32 and I'm sure on the Mac. The problems with
interrupting are the same.

Hope this helps.

Martin
--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
···············@wavehh.hanse.de http://cracauer.cons.org  Fax.: +4940 5228536
"As far as I'm concerned,  if something is so complicated that you can't ex-
 plain it in 10 seconds, then it's probably not worth knowing anyway"- Calvin