cat@pluto.dss.com (Iain Wacey) (04/29/91)
How does the w command determine how long someone has been idle? We are writing a login protocol using our own devices and w always reports users on these devices as being idle for a long period of time. So how does w compute the idle time? Iain Wacey cat@pluto.dss.com
jik@athena.mit.edu (Jonathan I. Kamens) (04/30/91)
In article <4274@pluto.dss.com>, cat@pluto.dss.com (Iain Wacey) writes: |> How does the w command determine how long someone has been idle? It checks the access time on the device file (i.e. the st_atime field of the stat structure obtained by calling stat() on the user's tty device. |> We are |> writing a login protocol using our own devices and w always reports |> users on these devices as being idle for a long period of time. Do your devices correctly update their access times when appropriate? -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710
slootman@dri.nl (Paul Slootman) (04/30/91)
jik@athena.mit.edu (Jonathan I. Kamens) writes: >In article <4274@pluto.dss.com>, cat@pluto.dss.com (Iain Wacey) writes: >|> How does the w command determine how long someone has been idle? > > It checks the access time on the device file (i.e. the st_atime field of the >stat structure obtained by calling stat() on the user's tty device. > >|> We are >|> writing a login protocol using our own devices and w always reports >|> users on these devices as being idle for a long period of time. > > Do your devices correctly update their access times when appropriate? I once hacked a program to show idle time (on our System V, we don't have 'w'). Only checking the access time (and mod. time) on the device file may not be enough; if the user is running some program that sits around calculating something for 20 minutes without generating any output, the user is apparently idle (hmmm, I guess *he* is, the terminal isn't...). If your 'ps' has a field to show the state of the process (e.g. S for sleeping less than 20 seconds, I for sleeping longer than 20 seconds), you can double-check by running 'ps'. Paul. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= : slootman@dri.nl : You are wise, witty and wonderful, but you : : ...!hp4nl!dri500!slootman : spend too much time reading this sort of trash. : =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
cudcv@warwick.ac.uk (Rob McMahon) (05/01/91)
In article <1019@dri500.dri.nl> slootman@dri.nl (Paul Slootman) writes: >I once hacked a program to show idle time (on our System V, we don't have >'w'). Only checking the access time (and mod. time) on the device file may >not be enough... > >If your 'ps' has a field to show the state of the process (e.g. S for >sleeping less than 20 seconds, I for sleeping longer than 20 seconds), you >can double-check by running 'ps'. Beware, even this isn't enough. If the user is running an editor which talks to /dev/tty, all the user has to do is stop typing for 20 seconds and he gets marked as idle. Killing him off is not always appreciated at this point. I think last time this discussion went round, it was decided there wasn't any sensible way to determine the real idle time. Rob -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England