Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > Process Explorer
  New Posts New Posts RSS Feed: BUG: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

BUG: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE

 Post Reply Post Reply
Author
Message
James Papp View Drop Down
Newbie
Newbie


Joined: 07 February 2006
Online Status: Offline
Posts: 1
Post Options Post Options   Quote James Papp Quote  Post ReplyReply Direct Link To This Post Topic: BUG: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
    Posted: 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.

Back to Top
Mark View Drop Down
Admin Group
Admin Group


Joined: 04 June 2005
Location: United States
Online Status: Offline
Posts: 465
Post Options Post Options   Quote Mark Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
kjohnston View Drop Down
Newbie
Newbie
Avatar

Joined: 05 February 2007
Online Status: Offline
Posts: 1
Post Options Post Options   Quote kjohnston Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down