The ExitProcess function ends a process and all its threads.
Specifies the exit code for the process, and for all threads that are
terminated as a result of this call. Use the GetExitCodeProcess function to retrieve the process's exit value. Use the GetExitCodeThread function to retrieve a thread's exit value.
This function does not return a value.
ExitProcess is the preferred method of ending a process. This function provides a clean
process shutdown. This includes calling the entry-point function of all attached
dynamic-link libraries (DLLs) with a value indicating that the process is
detaching from the DLL. If a process terminates by calling TerminateProcess, the DLLs that the process is attached to are not notified of the process
After all attached DLLs have executed any process termination value, this
function terminates the current process.
Terminating a process causes the following:
| UINT uExitCode
||// exit code for all threads
Terminating a process does not cause child processes to be terminated.
Terminating a process does not necessarily remove the process object from the
operating system. A process object is deleted when the last handle to the
process is closed.
The ExitProcess, ExitThread, CreateThread, CreateRemoteThread functions, and a process that is starting (as the result of a call by CreateProcess) are serialized between each other within a process. Only one of these events
can happen in an address space at a time. This means the following
- All of the object handles opened by the process are closed.
- All of the threads in the process terminate their execution.
- The state of the process object becomes signaled, satisfying any threads that
had been waiting for the process to terminate.
- The states of all threads of the process become signaled, satisfying any
threads that had been waiting for the threads to terminate.
- The termination status of the process changes from STILL_ACTIVE to the exit
value of the process.
CreateProcess, CreateRemoteThread, CreateThread, ExitThread, GetExitCodeProcess, GetExitCodeThread, OpenProcess, TerminateProcess
- During process startup and DLL initialization routines, new threads can be
created, but they do not begin execution until DLL initialization is done for the
- Only one thread in a process can be in a DLL initialization or detach routine
at a time.
- ExitProcess does not return until no threads are in their DLL initialization or detach
Programming books recommended by Amazon.com
More programming books on Amazon.com