Page 1 of 1
Interrupting a hanging or waiting system
Posted: Wed Nov 09, 2005 12:44 am
by SimpleMind
Hi,
Maybe someone can help me.
I'm programming most of the times code that has to to with communication and have code that hangs when I have an incorrect buffersize

or other insane parameters.
I need a utility or maybe that someone know some code how to interrupt a infinite loop, infinite waiting processes etc. I think of Ctrl+Break or something. Now I use ctrl+alt+delete. But that does terminate the whole program. I need something that does stop the code only the code running at the moment and than return to its normal process the program I'm working in.
Regards,
Marcel
Posted: Wed Nov 09, 2005 1:31 am
by Chris
If you know where the loop is, you can insert a GetAsynKeyState() function for break and exit a loop.
It's not really an example, but...
Ctrl+Return stop the loop
Code: Select all
Procedure InfiniteLoop()
Repeat
If GetAsyncKeyState_(#VK_CONTROL) And GetAsyncKeyState_(#VK_RETURN)
ProcedureReturn
EndIf
ForEver
EndProcedure
InfiniteLoop()
Debug "Program Stopped"
End
Posted: Wed Nov 09, 2005 3:16 am
by Sub-Routine
So you know that you are using an invalid buffer size and the program is crashin and someone should explain how you can avoid this?
Posted: Wed Nov 09, 2005 4:03 am
by Dare2

Perhaps more that unexpected insane things happen and a way to break in and find out where the problem lies is needed?
You can't use something like OllyDbg?
Or write temporary code in potential infinite loop areas that says "uh oh, elapsedmillisecs has got pretty high and I'm still here so I'll abort"? Or similar "this doesn't seem right" code?
Posted: Wed Nov 09, 2005 5:24 pm
by dell_jockey
the above suggestions are very valid indeed, ie. solve the problem from the inside first....
After that, you could write a watchdog service that kills and/or restarts the process if it discovers that your application isn't responding anymore. Of course, this can only work, if an external process has a way of determining the state of your application...
Posted: Wed Nov 09, 2005 6:13 pm
by thefool
show it @ a thread, then you can control it.
Posted: Thu Nov 10, 2005 10:53 am
by SimpleMind
Dare2 wrote:[...]You can't use something like OllyDbg?[...]
I did a fast scan and will study this program. It's not really what I was looking after but you set me up a trail for other problems I have and can discover.
[...] Or write temporary code in potential infinite loop areas that says "uh oh, elapsedmillisecs has got pretty high and I'm still here so I'll abort"? Or similar "this doesn't seem right" code? [...]
Actually this option is present in the program I use. I will activate this option so I can see if it really works.
Thanks,
Marcel
Posted: Thu Nov 10, 2005 10:57 am
by SimpleMind
dell_jockey wrote:[..]After that, you could write a watchdog service that kills and/or restarts the process if it discovers that your application isn't responding anymore. Of course, this can only work, if an external process has a way of determining the state of your application [...]
It's an idea. Don't know yet how to do but as TheFool said maybe with a thread.
Can a Spawn process also being controlled and check the state?
Regards,
Marcel