Interrupting a hanging or waiting system

Windows specific forum
User avatar
SimpleMind
Enthusiast
Enthusiast
Posts: 112
Joined: Sun May 18, 2003 12:40 pm
Location: Netherlands

Interrupting a hanging or waiting system

Post 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 :D 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
Give me books, fruit, french wine, fine weather and a little music.
John Keats
Chris
User
User
Posts: 60
Joined: Wed Jun 11, 2003 4:54 pm
Location: Somewhere... But i can see you!

Post 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
My english is bad !!!... It's normal, i'm french :lol:
My english is not really the English.
It's the FrogLish (Froggy's English) ;)
Sub-Routine
User
User
Posts: 82
Joined: Tue May 03, 2005 2:51 am
Location: Wheeling, Illinois, USA
Contact:

Post 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?
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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?
@}--`--,-- A rose by any other name ..
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post 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...
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

show it @ a thread, then you can control it.
User avatar
SimpleMind
Enthusiast
Enthusiast
Posts: 112
Joined: Sun May 18, 2003 12:40 pm
Location: Netherlands

Post 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
Give me books, fruit, french wine, fine weather and a little music.
John Keats
User avatar
SimpleMind
Enthusiast
Enthusiast
Posts: 112
Joined: Sun May 18, 2003 12:40 pm
Location: Netherlands

Post 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
Give me books, fruit, french wine, fine weather and a little music.
John Keats
Post Reply