I know. But just starting a process doesn't automatically associate it with the parent. Process Explorer, which I highly recommend, highlights Jobs in a ochre. They are seldom used. I see trees of processes started by a project build, some programs such as Open Office, the virus checking system, and of course Explorer and the various command shells, and from using git. None of them use Job objects.
—John | [reply] |
\BaseNamedObjects\PostgreSQL_6932
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
But just starting a process doesn't automatically associate it with the parent.
From the documentation that was available, that certainly used to be the case, indeed the MSDN used to shy away from using terms like "parent" and "child". Since Win2000 I wouldn't be so sure, although it does depend on what you mean by associate.
The history of Win32 APIs to iterate through processes is checkered, there used to be at least two rival systems, or even browsing HKEY_PERFORMANCE_DATA. However from W2k there was this (code extract from an XS module):
static int getppid(void) {
HANDLE hToolSnapshot;
PROCESSENTRY32 Pe32 = {0};
BOOL bResult;
DWORD PID;
DWORD PPID = 0;
PID = GetCurrentProcessId ();
hToolSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hToolSnapshot == INVALID_HANDLE_VALUE) {
return 0;
}
Pe32.dwSize = sizeof(PROCESSENTRY32);
bResult = Process32First(hToolSnapshot, &Pe32);
if (!bResult)
return 0;
while ( Process32Next(hToolSnapshot, &Pe32) ) {
if (Pe32.th32ProcessID == PID) {
PPID = Pe32.th32ParentProcessID;
break;
}
}
/* Expected */
if (GetLastError() == ERROR_NO_MORE_FILES) {
SetLastError(ERROR_SUCCESS);
}
return PPID;
}
Apologies for displaying a foreign language on this site. | [reply] [d/l] |
I also noticed in the perl source code for PP_system that it was doing its own associating, so it knew who to propagate the BREAK signal into. So, add to that processes that explicitly keep track of their (immediate) children.
| [reply] |