0

(Visual Studio 2010 - C++) Hello,

I'm trying to set a JOB to a process, but AssignProcessToJobObject returns ACCESS_DENIED and IsProcessInJob returns TRUE.

I call IsProcessInJob to a process immediately after call CreateProcess (Suspended) end tried call IsProcessInJob with my process (a few lines after main entry point) and it returns true.

void main()
{   
    BOOL bIsInJob;

    IsProcessInJob( GetCurrentProcess(), NULL, &bIsInJob );
    printf( "IsProcessInJob (me): %s\n", bIsInJob ? "true" : "false" ); 
// RET True ! inside and outside IDE
   ...

Someone saw it before?

Thanks for any help. Sources: Kill child process when parent process is killed How do I automatically destroy child processes in Windows?

Community
  • 1
  • 1
Rafael
  • 345
  • 3
  • 16
  • Have you checked the return value of IsProcessInJob to see if it is succeeding? Is this the main process or the subprocess? – Harry Johnston Aug 27 '11 at 07:08
  • IsProcessInJob (5th line) returns 1. Main process. (child process is notepad) – Rafael Aug 27 '11 at 15:16
  • Looks like your process really is in a job, then. This could be due to software running on your machine, although it is unusual. Are you able to try running your code on a test machine with no other software installed? – Harry Johnston Aug 28 '11 at 03:12
  • Also - you could try QueryInformationJobObject, perhaps with JobObjectBasicProcessIdList, to see what you can find out about the mystery job. – Harry Johnston Aug 28 '11 at 03:14

1 Answers1

1

I found.

For some reason, my process was child of Explorer.exe then Explorer set a job to my process and the notepad (my child) inherits this job.

I could not find until see with ProcessExplorer. I can not saw my process in process list, when i find below Winlogon->Explorer, i understood.

Resolution: CREATE_BREAKAWAY_FROM_JOB

if (!CreateProcess(L"c:\\windows\\system32\\notepad.exe",  L"", NULL, NULL, FALSE,
        CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &startupInfo, &processInformation))
...

Thanks for your comments, patience and time.

Rafael
  • 345
  • 3
  • 16