RtTerminateProcess

RtTerminateProcess terminates the specified process and all its threads.

Syntax

Copy
BOOL RtTerminateProcess(
    HANDLE hProcess,
    UINT uExitCode
);

Parameters

hProcess

A handle to the process to terminate. The handle must have PROCESS_TERMINATE access. If an invalid handle is specified, the function fails and sets the last error to ERROR_INVALID_HANDLE.

uExitCode

The exit code for the process and for all threads terminated by this call. Use RtGetExitCodeProcess to retrieve the process's exit value. Use GetExitCodeThread to retrieve a thread's exit value.

Return Value

If the function succeeds, it returns TRUE. If the function fails, it returns FALSE..

To get extended error information, call GetLastError.

Remarks

RtTerminateProcess is used to unconditionally cause a process to exit. It causes all threads within a process to terminate, and causes a process to exit, but RTDLLs attached to the process are not notified that the process is terminating.

Important: Use this function only in extreme circumstances. The state of global data maintained by dynamic-link libraries (RTDLLs) may be compromised if RtTerminateProcess is used rather than exit or ExitProcess.

Terminating a process causes the following:

  1. All the object handles opened by the process are closed.
  2. All the threads in the process terminate their execution.
  3. The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate.
  4. The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate.
  5. The termination status of the process changes from STILL_ACTIVE to the exit value of the process.

Terminating a process does not cause child processes to be terminated.

Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

Rtapi.h rtkrnl.lib

See Also: