Unique process id (not pid) and accounting daemon

cronfy cronfy at gmail.com
Thu Jan 28 14:16:30 UTC 2010


>> 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.

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

-- 
// cronfy


More information about the freebsd-hackers mailing list