tags:

views:

618

answers:

5

What is the best way to kill a critical process?

+6  A: 

It's critical for a reason so you probably shouldn't be killing it at all. The best way is to shut down the box lest you leave it in a dangerous state.

If you choose to ignore my warning, here is some sample C++ code to do it.

paxdiablo
Ok. Well thank you for the life lesson. However, if I NEEDED to kill a system process, how would I do so.
ixo
Sorry, ixo, didn't mean to sound condescending, added a link for you.
paxdiablo
Oh no, you did not sound condescending. You were just being quite logical and using reasoning :)Thank you for the link kind sir.
ixo
Killing a critical system process means that the machine is pretty much hosed and can't do anything (i.e. can't authenticate users, can't create remote threads, etc). Don't do this.
Paul Betts
+1  A: 

Invoking the kill function in signal.h is one way to killing a process in C. No idea about the alternations in C++.

Killing a Process in C

Edit : Have a look on this code.

WIN 32 API example

Chathuranga Chandrasekara
Thank you, I love the link btw! (bookmarked)What would be the best way via Windows API?
ixo
This looks like POSIX, not Windows.
strager
+1  A: 

with a wrench

in the library

Steven A. Lowe
+3  A: 

This knowledge base article describes how to do it. You first call SeDebugPrivilege() to obtain the privileges to terminate processes, then you call OpenProcess() with the PROCESS_TERMINATE flag to get a handle to the process you wish to terminate, and then finally you call TerminateProcess() to terminate the process.

Adam Rosenfield
+2  A: 

Yup, do what Adam suggested. Then watch as your machine bluescreens since you just terminated a critical process :) (btw, to be clear: Adam's suggestion is 100% accurate, it's not my intent to criticize it at all).

Why do you want to do this? There's a reason they're called critical processes.

Larry Osterman
I recall one day I had a services control panel that was stuck so I decided to kill it from task manager - hmm what could the name be I asked myself - obviously it must be services.exe
1800 INFORMATION
In case you are wondering, no it isn't and the machine bluescreened
1800 INFORMATION