Solved

Monitoring an application with C++

Posted on 2004-09-21
3
263 Views
Last Modified: 2008-01-16
Hi,

I want to monitor an application written in MFC which crash some times, what I want to do is, get rid of Microsoft popup message and restart the program in monitor program, it's important the program is restart again automatically, cuz there is no operator around to restart the application, I tried to override ProcessWndProcException in the application but still get the popup, the application is a consol application , then I used __try __except in main , but still get the popup, I don't know when in code it crashes and don't want to go in all my code and add try and catch, I was looking at CreateProcess as well, but still it doesn't help to get rid of popup. So I am looking for a solution for monitoring and spawn my process, and if it crashes restart it again.

regards
/m
0
Comment
Question by:Marjaneh
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 12113775
>>what I want to do is, get rid of Microsoft popup message and restart the program in monitor
>>program

IF you have the code to the MFC app, add

SetErrorMode(SEM_NOGPFAULTERRORBOX);

so the message box will not come up. Then, start it from a batch file like

@echo off
:respawn
start /WAIT c:\path\theapp.exe
goto respawn
0
 

Author Comment

by:Marjaneh
ID: 12120700
Hi jkr,

Thanks for your comment, it doesn't work when crashes happend in a thread I guess, I tried to in our lab and I still get the popup, but when I simulate a null pointer exception in main in my computer it doesn't come up. I don't want to use batch file to monitor I want to have some statistic as well when it crashes, so I put that in both monitor program and in the main of MFC application.
I will investigate more and get back.

/BR
0
 

Author Comment

by:Marjaneh
ID: 12317021
Hi jkr,
I added this command to the command you sugested and now it works, I think this one do the job  but because no one hase answered me so I will give you the points.
thank you.

you can use: SetUnhandledExceptionFilter( __XceptFilter);

which

LONG WINAPI __XceptFilter (EXCEPTION_POINTER *pExp)
{
......
return EXCPTION_EXECUTE_HANDLER; // or some other code
}
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question