tags:

views:

121

answers:

5

Is there a (more or less) easy way to force the process of a windows application to hang, and not respond? Or is this entirely dependent on the application/process in question?

Edit: What I wanted to try is this: The application in question has a web GUI, and several running processes in the background. There was a report that when one of these processes crashed, the web GUI stopped responding. I would like to try and reproduce that, but I realize it might not be that easy.

+2  A: 

If you can get a handle to a thread in the application, you may be able to call SuspendThread() which will bring that thread to a screeching halt.

(Note that my answer assumes you want to make another application hang. There are a myriad of ways to make your own application hang, deliberately or not.)

In response to your edit, I recall that Process Explorer has the ability to manually suspend specific threads within a process. That would definitely be worth a try.

Greg Hewgill
A: 

while (true) {}

KristoferA - Huagati.com
just an application, not the entire OS.
Geo
@Geo while (true) {} in a process will _not_ hang the entire OS, at least not Windows Vista.
Daniel Daranas
how do you insert that code in a running process?
Geo
When I replied there was no mention of a running process. And as Daniel already said, that will not hang the OS unless we're talking 16-bit windows or other non-multitasking OSes.
KristoferA - Huagati.com
+1  A: 

It depends on what you mean by "hang" and "not respond". Any GUI app that stops processing messages will become unresponsive as far as the user is concerned.

anon
unknown (google): a hook would do that if you need to stop only gui messages.
Umair Ahmed
A: 

an easy way would be set the priority of application you want to hang to minimum and then run a loop infinitely in your application at low priority. this would starve the other application. not perfect but simple

Umair Ahmed
A: 

If you could change code of that process so just insert for(;;); somewhere in it. If you could not change the code the easiest way to suspend process is using Process Explorer. Just right-click on wanted process and select Suspend in menu.

Kirill V. Lyadvinsky
Thanks - process explorer was usefull, and it seems to do the trick.