Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!uunet!mcsun!hp4nl!dri500!slootman From: slootman@dri.nl (Paul Slootman) Newsgroups: comp.unix.programmer Subject: Re: idle time for w command Keywords: w Message-ID: <1019@dri500.dri.nl> Date: 30 Apr 91 07:20:10 GMT References: <4274@pluto.dss.com> <1991Apr29.212101.10931@athena.mit.edu> Organization: DataCount Register Informatici, Wierden, The Netherlands Lines: 30 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. : =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=