osTerminateTask function
BOOL osTerminateTask(
  HANDLE Handle

A task handle.

Return value:

TRUE on success or FALSE on failure. Use osGetLastError function to obtain extended error information.


Function terminates a specified task.

To terminate a current task, use the osExitTask, which also allow setting the task exit code. When the osTerminateTask function is used, the exit code is always set to ERR_TASK_TERMINATED_BY_OTHER.

When a task is terminated, all of the owned critical sections are released and marked as abandoned. When the OS_ALLOW_OBJECT_DELETION is set to 1, all of the opened objects are closed. When object is not opened by any task, it is deleted.

The osTerminateTask function terminates current task, but it do not deletes the task object instance. To delete task object, the osCloseHandle must be performed. The task object will be deleted when it is terminated and all tasks that opened this object earlier close it. If it is closed before task termination, there is no way to delete this object.

Function is available only, when the value of OS_TERMINATE_TASK_FUNC constant is set to 1. When function is not used, it may be disabled to reduce the output code.

SpaceShadow documentation