Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!usc!ucsd!pacbell.com!ames!haven!udel!princeton!phoenix.Princeton.EDU!pfalstad From: pfalstad@phoenix.Princeton.EDU (Paul Falstad) Newsgroups: comp.unix.questions Subject: Re: "Monitoring" a process Message-ID: <5569@idunno.Princeton.EDU> Date: 22 Jan 91 07:53:31 GMT References: <279B5779.58AF@telly.on.ca> Sender: news@idunno.Princeton.EDU Organization: The E. Henry Thripshaw Fan Club Lines: 19 rickc@telly.on.ca (Rick Copley) wrote: >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 ?? > >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. Yes, there should be, but there isn't. You need to read /vmunix's name list, open /dev/kmem, and traverse the kernal process table. It's not pretty at all. Reading the output of some variant of ps is probably the easiest solution in this case. -- Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD In the heat of composition I find that I have inadvertently allowed myself to assume the form of a large centipede. I am accordingly dictating the rest to my secretary.