From: Bronek Kozicki (brok_at_[hidden])
Date: 2006-07-24 02:55:16
Vladimir Prus wrote:
> On Monday 24 July 2006 01:36, Bronek Kozicki wrote:
>> Bronek Kozicki wrote:
>>> I still do not get it right :-S I will send you another mail with another
>>> patch today, now I just want to let you know that the code is still (a
>>> little) buggy - it closes dialogs displayed by procexp.exe when run
>>> instead of taskmgr.exe, which is child of winlogon.exe (which in turn is
>>> child of smss.exe). Nothing critical, but annoying.
>> This should fix the problem, I started testing.
> sorry for getting picky, but can you send me either diff (preferred), or a
> modified file?
Please find attached. Tests results are OK.
--- C:\Documents and Settings\Bronek Kozicki\Desktop\execnt.c Mon Jul 24 06:50:15 2006 UTC
+++ C:\DEVEL\BOOST_RTEST\boost\tools\jam\src\execnt.c Mon Jul 24 06:53:01 2006 UTC
@@ -1008,11 +1008,13 @@
/* now that the children are all dead, kill the root */
/* Recursive check if first process is parent (directly or indirectly) of
-the second one. Both processes are passed as process ids, not handles */
+the second one. Both processes are passed as process ids, not handles.
+Special return value 2 means that the second process is smss.exe and its
+parent process is System (first argument is ignored) */
is_parent_child(DWORD parent, DWORD child)
HANDLE process_snapshot_h = INVALID_HANDLE_VALUE;
@@ -1063,14 +1065,18 @@
child of smss.exe process, which in turn is directly child of
System process, which always has process id == 4 .
This check must be performed before comparison of process
creation time */
if (stricmp(pinfo.szExeFile, "csrss.exe") == 0
- || stricmp(pinfo.szExeFile, "smss.exe") == 0)
+ && is_parent_child(parent, pinfo.th32ParentProcessID) == 2)
- if (is_parent_child(4, pinfo.th32ParentProcessID))
- return 1;
+ return 1;
+ else if (stricmp(pinfo.szExeFile, "smss.exe") == 0
+ && pinfo.th32ParentProcessID == 4)
+ return 2;
if (hchild != 0)
HANDLE hparent = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pinfo.th32ParentProcessID);
@@ -1088,11 +1094,11 @@
1. we failed to read process creation time
2. child was created before alleged parent */
if (tchild == 0.0 || tparent == 0.0 || tchild < tparent)
- return is_parent_child(parent, pinfo.th32ParentProcessID);
+ return is_parent_child(parent, pinfo.th32ParentProcessID) & 1;
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk