supervisory program

  • Thread starter Thread starter David D
  • Start date Start date
D

David D

Does anyone know of a way or a software program that can keep another
program running?
Here is my situation. My programmers have a beta version of code that keeps
crashing and then the software closes. When that happens I want to open the
program up again. This is something I want to do just to get by for the
short term.

Thanks
 
It is good to have such program for long run as well.
You can use hardware WDT is you have it, to guard your supervisor program.

And from inside of your supervisor program, you can use CreateProcess and
related functions to launch and keep track of proper functioning of any app
started by it.
If app closes or terminates you can always spawn new process.

Also check functions associated with AssignProcessToJobObject.
This can help you to put in box all processes spawned from process that you
monitor. Then if you decide to kill process, you can kill job instead and
all processes found in this job will be terminated. This come very handy.

Regards,
Slobodan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have an opinion on the effectiveness of Microsoft Embedded newsgroups? Tell
Microsoft!
https://www.windowsembeddedeval.com/community/newsgroups
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
David,

Many ways to accomplish that. E.g., hardware or software watchdog code.

If you have concerns about only one program - you can write your own
service/agent app that will watch for the software. A few ways how to
implement the agent app:

1. Your agent will start the app itself (CreateProcess, e.g.) and then
wait for the process handle to release (WaitForSingleObject API).

2. The agent may timely search for some of the app objects or object
states - main window (FindWindow/EnumWindows APIs, custom class name/custom
title), any kernal object (mutex, semaphore, event, etc.)

3. Timely open the process (OpenProcess/ShellExecute APIs) or checking
if the process is still running (ToolHelp32 API
Process32First/Process32Next, PSAPI EnumProcesses), or quering process info
from OS (NT ZwQuerySystemInformation).

4. Using Performance Data Helper or WMI performance object to watch on
your process performance.

5. Again from your agent app you can see if the process hung
(SendMessageTimeout API, IsHungAppWindow and IsHungThread).

That is all I could recall at the moment.
 
Hi
Sometimes I use a .bat file like below.
Whenever 'MyProgram' is terminated, it is restarted by the loop in the .bat file

:again
start /WAIT MyProgram.exe
goto again

Lasse
 
Lasse,

Interesting solution :-)
But then you, probably, always see the CMD window on the screen, don't you?
 
I think that the CreateProcess()/WaitForSingleObject() method is probably best, as it does not involve any polling in the background

If you are implementing a custom shell, you could make the shell app a background task that spawns off the actual UI with CreateProcess() -- should the UI exit for any reason, the background task can then handle the situation accordingly, based on the exit code of the UI process (you can use GetExitCodeProcess() to determine why the UI exited)

Alternatively, you could implement the background task as a boot service..

-JW
 
Back
Top