![]() |
BUG: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE |
Post Reply
|
| Author | |
James Papp
Newbie
Joined: 07 February 2006 Online Status: Offline Posts: 1 |
Post Options
Quote Reply
Topic: BUG: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSEPosted: 07 February 2006 at 7:26pm |
|
PE interferes with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE limit on unnamed jobs. It seems to duplicate the job handle so when the parent or the single owner of the job handle dies, the job is not terminated, which then prevents child processes from terminating. When closing PE, all child process in that job interestingly enough are terminated on the spot. When PE is not running everything works normally. Here is some example code that demonstrates the problem: #define _WIN32_WINNT 0x0500 #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { HANDLE hJob = CreateJobObject(NULL, NULL); JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 }; jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)); AssignProcessToJobObject(hJob, GetCurrentProcess()); PROCESS_INFORMATION pi = { 0 }; STARTUPINFO si = { sizeof(si) }; CreateProcess(TEXT("C:\\Windows\\System32\\Notepad.exe"), NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); SleepEx(1000000, false); return 0; } When PE is not running, closing down the console window will force Notepad.exe to terminate as it should. When PE is running, closing down the console window does not close down Notepad.exe; instead, you must then close PE itself to get the last handle of the job closed (or at least I’m assuming), so that Notepad.exe is terminated. This is a real issue as just running PE causes some applications to behave differently. It took us forever to trace it to PE, as we were using PE to test the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE limit, as it has some cool properties on Jobs. James. |
|
![]() |
|
Mark
Admin Group
Joined: 04 June 2005 Location: United States Online Status: Offline Posts: 465 |
Post Options
Quote Reply
Posted: 08 February 2006 at 11:20am |
|
I've verified the behavior you report. Process Explorer keeps the job open as a perf optimization and so that it can know if a process leaves a job. I'm not going to be able to fix that in this 10.0x series, but will consider it in the future.
|
|
![]() |
|
kjohnston
Newbie
Joined: 05 February 2007 Online Status: Offline Posts: 1 |
Post Options
Quote Reply
Posted: 05 February 2007 at 6:23pm |
|
Wow this bug really bit me as I tried to figure out how jobs work. Looks like it is still not fixed - I'm just glad I found this post. Any ETA on a fix?
|
|
![]() |
|
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |