How does screenblank(1) calculate idle time

Guy Harris auspex!guy at uunet.uu.net
Tue Apr 25 16:28:32 AEST 1989


>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.



More information about the Comp.sys.sun mailing list