Unique process id (not pid) and accounting daemon

Alfred Perlstein alfred at freebsd.org
Sat Jan 30 22:13:53 UTC 2010


* cronfy <cronfy at gmail.com> [100128 06:16] wrote:
> >> To ensure that process in the process tree and process in the
> >> accounting file are the same, I want to add unique process identifier
> >> (uint64_t) to 'proc' struct in sys/sys/proc.h and increment it for
> >> every process fork. I see it is possible to do this just before
> >> sx_sunlock() in fork1() in sys/kern/kern_fork.c.
> > Now that I know this, I would suggest simply recording the start
> > time as the serial number, then using pid+recorded_start_time as
> > your serial number.
> 
> This may lead to duplicate ids: pid may be reused and time may be
> shifted to give exactly the same start_time as it was used with this
> pid earlier. Simple increment will work fine.

You're right.  I was still stuck in "start time doesn't change" mode.
(assuming that if the time changed that the "start time" used to
tag processes would be incremented akin to your increasing number).

meh :)

> Ok, as far as no one else commented at my idea, I assume it is not
> completely stupid and will try to implement this :)

It sounds good! 

-- 
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer


More information about the freebsd-hackers mailing list