Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: auspex!guy@uunet.uu.net (Guy Harris) Newsgroups: comp.sys.sun Subject: Re: How does screenblank(1) calculate idle time Keywords: Software Message-ID: <1359@auspex.auspex.com> Date: 25 Apr 89 06:28:32 GMT References: <467@parcplace.pplace.COM> Sender: usenet@rice.edu Organization: Auspex Systems, Santa Clara Lines: 15 Approved: Sun-Spots@rice.edu Original-Date: 1 Apr 89 08:34:47 GMT X-Sun-Spots-Digest: Volume 7, Issue 245, message 4 of 15 >What calls does it use? My guess (I don't have source handy, it forks so running "trace" on it directly doesn't work, and attaching "trace" to it caused it to die when I tried it) is that it uses the same mechanism as other programs - it "stat"s "/dev/kbd" and "/dev/mouse", and treats the last access time ("st_atime") as the last time any input was generated on the device in question. (It might also look at "/dev/console" in the same way as well.) Basically, once input arrives, a "read" - or its moral equivalent in the SunView kernel code (don't ask) - is generally done soon afterwards, which causes the accessed time to be updated. Programs such as "w" use the same trick, treating the last access time on a tty as the time something was last typed on it, under the assumption that, most of the time, something's blocked trying to read from it.