Crashed Programs in Windows

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Zorth
Forum Commoner
Posts: 76
Joined: Fri Feb 20, 2004 8:00 pm

Crashed Programs in Windows

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
Zorth
Forum Commoner
Posts: 76
Joined: Fri Feb 20, 2004 8:00 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post 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...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Asserts won't stop access violations and things, while exceptions can.
Zorth
Forum Commoner
Posts: 76
Joined: Fri Feb 20, 2004 8:00 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
  }
}
Zorth
Forum Commoner
Posts: 76
Joined: Fri Feb 20, 2004 8:00 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the try..catch should surround all your code so it catches any exception thrown anywhere in the application.
Zorth
Forum Commoner
Posts: 76
Joined: Fri Feb 20, 2004 8:00 pm

Post by Zorth »

Alright, thanks :)
Post Reply