SPUG: tracking PIDs

Jonathan Gardner jgardn at alumni.washington.edu
Tue Aug 27 16:41:33 CDT 2002

On Tuesday 27 August 2002 10:13 am, Andrew Sweger wrote:
> On Mon, 26 Aug 2002, Jonathan Gardner wrote:
> > There is a small chance that the child has been long dead and you have
> > cycled through the available PIDs, and a different process is running
> > as that PID, but what can you do about that?
> If a somewhat unique value (other than a PID) is included in the command
> line of each process spawned in this particular system, this value's
> existence can be checked in /proc/$pid/cmdline on systems that support
> procfs. So, along with tracking PIDs, these unique values would also need
> to be tracked. If the PID is still alive (via the kill 0 test), check the
> cmdline to see if it still matches the previously recorded signature.

This is a nearly foolproof method.

I just thought of this as well. We could compare the creation time of the 
PID file, and the "beginning" of the process in question. How to figure out 
when a process started, or even how long it has been running (not how much 
CPU time it took) is beyond me at the moment. However, the two times should 
be similar, with the "Start" time earlier than the PID file creation, if 
not at the same time.

Jonathan Gardner

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org

More information about the spug-list mailing list