On Wed, Apr 05, 2006 at 09:30:06AM +0200, Martijn van Oosterhout wrote:
> On Wed, Apr 05, 2006 at 03:20:47AM -0400, mark@mark.mielke.cc wrote:
> > TerminateProcess takes a HANDLE, not a process identifier. Yes, they
> > provide the "kill" primitive, but only as a compatibility measure. A
> > "good" Windows process, should maintain a HANDLE to the process, and
> > kill the process using the HANDLE. This way, there is no race. The
> > HANDLE is also how you wait for the process to terminate normally.
> Which presents the solution, we should use the HANDLE on windows rather
> than the process identifier.
Yes.
> > I prefer the "Redmond" way, in that I find UNIX's use of integer
> > identifiers to be encouraging of race conditions. UNIX requires hacks
> > like minimizing PID reuse, because UNIX is the one that is broken. :-)
> Eh? A HANDLE is (or can be mapped to) an integer too. I don't see
> anything on that page about handle reuse. If you run a machine long
> enough I'm sure it can be reused also...
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.
Cheers,
mark
--
mark@mielke.cc / markm@ncf.ca / markm@nortel.com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | 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
bindthem...
http://mark.mielke.cc/