Page 1 of 1

Crashed Programs in Windows

Posted: Thu Jul 22, 2004 11:55 am
by Zorth
Hey all,

Not sure if this belongs here, but I didn't really see another place to put it. Basically, I'm using Windows XP right now. If I have a program that crashes in it, it will bring up a box that notifies me and all. It use to be some sort of "Error Report Service", but I managed to stop that, but of course Windows has another backup annoyance. The problem with this is that I have a few people who can remotely reboot this program by clicking a link, which triggers something called "pskill", which kills processes by their name: "pskill solitare.exe", using the System() function. Every time this box pops up after the program crashes, which of course is the time that I need people to kill the process so it can auto-start, it stops any attempt to kill the processs using Pskill.

So I guess my questions are:

Is there another way to allow people to remotely reboot a program using Windows XP? Or at least kill the process? I know people have talked about some sort of remote login, but I tried that out and it didn't really work as far as allowing remote logins.

Or

Is there a way to stop Windows from giving me this annoying box? The box comes up every time a program crashes, just simply saying "Your program blahblah.exe has noticed an error. All unsaved data will be lost.", or am I stuck here for eternity before I decide that Linux is better? :)

Thanks!

Posted: Thu Jul 22, 2004 12:16 pm
by feyd
I think the bigger problem is that these applications are crashing.. If they had proper error/exception handling, they wouldn't crash where Windows would have to intervene. Which programs are these that are crashing?

Posted: Thu Jul 22, 2004 8:12 pm
by Zorth
It's actually a game I'm hosting on the internet. Getting rid of all of the bugs would take a very long time, and be next to impossible, as we are always changing it and adding to the codebase. It's called a MUD(multi user dungeon). Other places I've gone to that have MUDs, they crash all the time. But they have ways to let other people reboot the game.

Posted: Thu Jul 22, 2004 8:17 pm
by feyd
Since you have the code it's fairly easy, throw exception handlers in there to catch all exceptions. This will allow you to soft-crash the app, and you could log the crash, maybe details of where it happened.. the callstack. Look into installing it as a service, most services are auto-restarted when they crash.

Posted: Thu Jul 22, 2004 9:12 pm
by Joe
Or a good alternative to exception's could possibly be asserts. Im not sure if it would be as reliable but should work...

Posted: Thu Jul 22, 2004 9:32 pm
by feyd
Asserts won't stop access violations and things, while exceptions can.

Posted: Fri Jul 23, 2004 2:55 am
by Zorth
Well, I have a debugger ;). But, debugging doesn't always give enough information to help me fix the problem. Therefore, I need a way to just stop Windows from bringing up this ugly box so I can let PSKILL kill the process. I'm pretty sure it is the thing Windows pops up that prevents it from killing it.

What was it you were talking about soft crashing the program?

Posted: Fri Jul 23, 2004 11:32 am
by feyd
Assuming you're using C++, add try..catch stuff around your code like so:

Code: Select all

int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprev, LPTSTR cmdline, INT cmdshow)
{
  try
  {
    // all code inside main/Winmain
  }
  catch(...)  // you'll leave this an ellipsis as it catches any exception thrown..
  {
    // add to a log here that it crashed maybe?
    // this is where you'd close out anything, if needed.
    exit(-1); // or something..
  }
}

Posted: Fri Jul 23, 2004 3:20 pm
by Zorth
Yeah this is C++ console program. So I will want to add try { } every loop and add a catch after every loop inside of the game loop? That way, try { } will, I guess, end once an error occures and catch() will end it?

Posted: Fri Jul 23, 2004 3:32 pm
by feyd
the try..catch should surround all your code so it catches any exception thrown anywhere in the application.

Posted: Fri Jul 23, 2004 4:27 pm
by Zorth
Alright, thanks :)