Terminating All Processes in a Job

[Previous] [Next]

Well, certainly one of the most popular things that you will want to do with a job is kill all of the processes within it. At the beginning of this chapter, I mentioned that Developer Studio doesn't have an easy way to stop a build that is in progress because it would have to know which processes were spawned from the first process that it spawned. (This is very tricky. I explain how Developer Studio accomplishes this in my Win32 Q & A column in the June 1998 issue of Microsoft Systems Journal.) I suspect that future versions of Developer Studio will use jobs instead because the code is a lot easier to write and you can do much more with it.

To kill all the processes within a job, you simply call

 BOOL TerminateJobObject( HANDLE hJob, UINT uExitCode); 

This is similar to calling TerminateProcess for every process contained within the job, setting all their exit codes to uExitCode.



Programming Applications for Microsoft Windows
Programming Applications for Microsoft Windows (Microsoft Programming Series)
ISBN: 1572319968
EAN: 2147483647
Year: 1999
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net