Best way to deal with OS events?

David T. Lewis lewis at mail.msen.com
Mon May 28 14:07:53 UTC 2001


On Mon, May 28, 2001 at 08:30:48AM -0400, Kevin Fisher wrote:
> 
> So my question is, how best to read an OS event like this from Squeak? 
> I'm thinking that OSProcess might be my best bet, but that would limit 
> portability.  I'm not sure exactly how the 'wakeup event' will appear...
> probably an APM related event, I imagine.
> 
> Any ideas?
>
Assuming Linux underneath, a quick and dirty hack with OSProcess would
be something like this:
  [(ConnectedUnixProcess
      command: 'sleep 5; echo I just slept 5 seconds')
          output inspect] fork

For an example of catching an OS signal and signaling a Smalltalk semaphore
see UnixOSProcessPlugin>>reapChildProcess. This mechanism provides a
callback triggered by an OS signal, and you could use something like
that to catch (for example) SIGUSR1 as an event trigger, possibly
scheduling the wakeup with a program run from /usr/bin/at.

OSProcess does not provide any generalized external event handling.
The right way to do it is with something like Lex Spoon posted on
http://www.cc.gatech.edu/~lex/squeak/ (see the sqaio.c and sqaio.h files
at the end of the page). This will enable a more general treatment of
"file events" and "socket events" similar to the way Tk/Tcl does it.
Hopefully something like this will be on the way as part of Ian's
source distribution.

- Dave





More information about the Squeak-dev mailing list