2

I know I can have the child process monitor the parent. Is there to have Windows do this automatically? After all, it does track the process launch hierarchy.

H H
  • 263,252
  • 30
  • 330
  • 514
James L
  • 16,456
  • 10
  • 53
  • 70
  • 1
    You cannot rely on jobs when your program gets started from a shortcut on the desktop. In Vista, the shell already uses jobs for appcompat. Big frown upside down when I discovered that. Not sure if it is still this way in Win7. A third guard process is the generic solution. – Hans Passant Mar 04 '12 at 19:27

2 Answers2

3

You can use Jobs, try the SetInformationJobObject function, the key is use the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE value in the LimitFlags member of the _JOBOBJECT_BASIC_LIMIT_INFORMATION struct passed to the function.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
3

You cannot do this nativly through C#. You will need to use PInvoke to call the Win32 Job API.

The API calls are in this answer: How do I automatically destroy child processes in Windows?

Community
  • 1
  • 1
Jared Shaver
  • 1,339
  • 8
  • 12