[comp.sys.sun] How does screenblank

khaw%pplace.COM@decwrl.dec.com (Mike Khaw) (03/31/89)

What calls does it use?

Mike Khaw
-- 
E-Mail:	Internet=khaw@parcplace.com, UUCP={uunet,sun,decwrl}!parcplace!khaw
USPS:	Parcplace Systems, Inc., 2400 Geng Road, Palo Alto, CA 94303
Phone:	(415) 859-1052

miker@central.sun.com (Mike Raffety) (04/22/89)

screenblank checks BOTH the access and modify time on the devices (usually
/dev/kbd and /dev/mouse).  When an event occurs on either, a read(2) is
done to get the data, and the access time (ls -lu) is updated.
screenblank simply watches to see when those times get "old".

guy@uunet.uu.net (Guy Harris) (04/25/89)

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