On Wed, Apr 05, 2006 at 09:58:54AM +0200, Martijn van Oosterhout wrote: > On Wed, Apr 05, 2006 at 03:38:28AM -0400, [EMAIL PROTECTED] wrote: > > Once upon a time, when I played with this stuff (I mostly use UNIX, not > > Windows), I concluded to myself that HANDLE was process-local, and that > > it was allocated. Meaning - it won't be re-used until you CloseHandle(). > > It's best then, to think of HANDLE as a opaque object. Regardless, of > > whether it is process-local or not, until you run CloseHandle(), it is > > yours to keep, and it won't be re-used. > HANDLE is process local? That is worse then, because then there's no > guarentee that each process will see a different identifier.
It's no different from a file descriptor on UNIX. Neither UNIX nor Windows promise that a process identifier is valid beyond the life of the process. UNIX avoids it from happening, as it is necessary to avoid races with system calls such as kill(). Windows does not have this problem. > The stats collector identifies processes by their process id, which > they get using getpid(). If instead they used a handle for their own > process (GetCurrentProcess() always returns -1, but you can apparently > clone it to get a real handle), you have no idea whether that handle is > unique amongst backends, because it's process local. > The stats collector doesn't have any open handles for the backend, it's > just a way for backends to identify themselves. It appears that process > handles are not up to the task either... > Do we have a plan C? Sure. Serial. Allocate on process start. Or, back to another topic from months ago - UUID generation... :-) Process identifier should not be used beyond the life of the process. As soon as wait() removes the process on UNIX, the process identifier is no longer valid, and could be reused. That the operating system tries to prevent problems by avoiding recycling isn't necessarily a good reason to exploit this capability. Cheers, mark -- [EMAIL PROTECTED] / [EMAIL PROTECTED] / [EMAIL PROTECTED] __________________________ . . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder |\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | | | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them... http://mark.mielke.cc/ ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend