Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

TerminateJobObject function

Terminates all processes currently associated with the job. If the job is nested, this function terminates all processes currently associated with the job and all of its child jobs in the hierarchy.

Syntax


BOOL WINAPI TerminateJobObject(
  _In_  HANDLE hJob,
  _In_  UINT uExitCode
);

Parameters

hJob [in]

A handle to the job whose processes will be terminated. The CreateJobObject or OpenJobObject function returns this handle. This handle must have the JOB_OBJECT_TERMINATE access right. For more information, see Job Object Security and Access Rights.

The handle for each process in the job object must have the PROCESS_TERMINATE access right. For more information, see Process Security and Access Rights.

uExitCode [in]

The exit code to be used by all processes and threads in the job object. Use the GetExitCodeProcess function to retrieve each process's exit value. Use the GetExitCodeThread function to retrieve each thread's exit value.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

It is not possible for any of the processes associated with the job to postpone or handle the termination. It is as if TerminateProcess were called for each process associated with the job.

Terminating a nested job additionally terminates all child job objects. Resources used by the terminated jobs are charged up the parent job chain in the hierarchy.

To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

CreateJobObject
Job Objects
OpenJobObject
Process and Thread Functions
TerminateProcess

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.