"Monitoring" a process

Rick Copley rickc at telly.on.ca
Tue Jan 22 08:04:55 AEST 1991


Can anyone out there tell me how to tell if a given process is actually
doing any thing (ie accumulating cpu time) from within a C program ??

On this NCR TOWER 32/800 running AT&T s5r3 (hacked by NCR, 2.00.02 is the NCR 
version number), I have found a file called /usr/include/sys/proc.h that seems 
to have all the stuff I need to "monitor" a process, but I can't figure out what
"function" to call to actually use it.

Reason I am looking is we have a problem with users NOT login off, and causing
swappage for the other users.  They are the kind that login, type for 20 seconds
and leave the terminal logged in for hours and hours.  I have taken a C 
program from UnixWorld Mag that looks at the users /dev/tty file to see when 
the last time they TYPED was. This is no go for when a user runs a very lengthy 
report that does no screen I/O.  The C program (called autologout.c) murders 
EVERYONE who does not access his/her tty port for more than a certain amount of 
time.

I realize I could muck around with the ps -t command and capture the cpu time
in a file and compare it to a few minutes ago and stuff like that, but it seems
like there should be a REALLY easy way to check if a process is "running" and 
accumulating cpu time.

Help, anyone ???

-- 

rickc at telly.on.can   "You can twist perception, but reality wont budge" - RUSH

uunet!telly.on.ca!rickc (Rick Copley)



More information about the Comp.unix.questions mailing list