Windows – What advantages does Ending Task have over Ending Process

processtask-managerwindows

From what I know, everytime we want to stop an app (or a frozen app), we will go TaskManager, select the app, Go to Process and terminate the process. "Ending Process" is preferred over "Ending Task" (sometimes "ending task" doesn't work anyway).

Image for End Task:

enter image description here

Image for End Process:

enter image description here

However, http://technet.microsoft.com/en-us/library/bb726964.aspx:

As you examine processes, note that although applications have a main process, a single application may start multiple processes. Generally, these processes are dependent on the main application process and are stopped when you terminate the main application process or use End Task. Because of this, you'll usually want to terminate the main application process or the application itself rather than dependent processes.

They are saying it is preferred to "End Task" because the process is stopped when I stop the app. But I don't understand their logic at all, Why not simply stop the process instead?

What advantages does Ending Task have over Ending Process?

Best Answer

For programs having at least one window, End Task does the same as clicking the X "Close" button – it sends the WM_CLOSE message to that window, asking it nicely to close. (For console windows, the equivalent is CTRL_CLOSE_EVENT.) The program can prompt the user to save changes, or do various cleanup tasks. If the process complies, Task Manager waits a few seconds and proceeds with terminating the process if it is still running.

If the process is frozen or otherwise not handling window messages it receives, then, of course, neither End Task nor the Close button can work. In those cases, Windows will usually ask you to end the program forcefully, but only after giving the program sufficient time to respond.

Meanwhile, the End Process button does not concern itself with tasks or windows – it calls the TerminateProcess() function and Windows destroys the process immediately, without notifying it or giving it any chance to clean up.

(Resources such as memory are released automatically once the process is gone; however, there might remain various temporary files if the program created them, and of course there's the risk of data corruption if the process is terminated in the middle of saving data.)

See also:

Related Question