From: Erik Faye-Lund Date: Tue, 19 Jan 2010 19:23:32 GMT Subject: Re: [PATCH v2 06/14] mingw: use real pid Message-ID: <40aa078e1001191123t7e8e9a47l46394d62648dfdb8@mail.gmail.com> In-Reply-To: <201001191919.16070.j6t@kdbg.org> On Tue, Jan 19, 2010 at 7:19 PM, Johannes Sixt wrote: > On Montag, 18. Januar 2010, Erik Faye-Lund wrote: >> On Sat, Jan 16, 2010 at 10:12 AM, Erik Faye-Lund wrote: >> > On Sat, Jan 16, 2010 at 9:03 AM, Johannes Sixt wrote: >> >> On Freitag, 15. Januar 2010, Erik Faye-Lund wrote: >> >>> No. If I do, the pid becomes invalid after the process is finished, >> >>> and waitpid won't work. I couldn't find anywhere were we actually were >> >>> closing the handle, even after it was finished. So I don't think we >> >>> leak any more than we already did (for non-daemon purposes). >> >> >> >> Previously, this handle was closed by _cwait() (it was the "pid"), so we >> >> didn't leak it. >> > >> > Oh, I see. My planned route with this (before I looked for where the >> > handle was closed), was to maintain some sort of list of each started >> > PID and their handle, and lookup in that list instead of using >> > OpenProcess. I guess that would solve the problem here, but it feels a >> > bit nasty. Not as nasty as introducing a leak, though. >> >> What I had in mind was something along these lines: > > Given that that the process ID is the user-visible (and system-wide unique) > identifier of a process, this looks like the only reasonable way to go. Your > implementation looks good as well. > >> +     /* store process handle */ > >        /* >         * The process ID is the human-readable identifier of the process >         * that we want to present in log and error messages. The handle >         * is not useful for this purpose. But we cannot close it, either, >         * because it is not possible to turn a process ID into a process >         * handle after the process terminated. >         * Keep the handle in a list for waitpid. >         */ > Much better, thanks. -- Erik "kusma" Faye-Lund