Log in

View Full Version : ExitProcess and TerminateProcess


wbe
November 29th, 2001, 17:28
What's the difference between the two? Is there any other API used to terminate (exit) a program?

Thanks

Fake51
November 29th, 2001, 18:04
Exitprocess is used by a program to terminate itself. Terminateprocess is used by a program to terminate another program.

Fake

Solomon
November 29th, 2001, 21:57
TerminateProcess doesn't give the victim a chance to free resources, while ExitProcess does.

Sure the best description is in MSDN.

DakienDX
November 30th, 2001, 02:45
Quote:
This function terminates the specified process and all of its threads.

[...]

Remarks
The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess.

TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating.

Terminating a process causes 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.
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.


Maybe not the best description, but all you need...

wbe
November 30th, 2001, 17:35
You are a great asset for this Forum.

Thanks a lot.