[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

Watchdog program for DOS application

Hi Experts,

I have to write a watchdog for a DOS application on Win98. It has to check each minute for:

- Is the program still running?
- Is the program hanging.

If the program is not running or is hanging, an action has to be taken.

What is the best way to watch the application. ( something like task-manager?)
Please insert code / function names

Thanks in advance.
Melissa
0
MelissaC
Asked:
MelissaC
  • 2
  • 2
  • 2
1 Solution
 
Gus012498Commented:
let the dos-program access/create a file in its main loop. The Win98 program checks the last file access time.

Regards, Gus
0
 
MelissaCAuthor Commented:
Thank you for your answer. I agree that it is a solution, we also thought about doing that, but I do believe there must be a "cleaner" solution. So I'll keep this question open for now. ( If I don't get another solution, you'll get the points.)
Thanks.
Melissa
0
 
alechkoCommented:
ok, here we go...

The first one is simple.
Use CreateProcess function to run the DOS application, you get a handle to that process in LPPROCESS_INFORMATION structure (last parameter).
Then you can use WaitForSingleObject function to check if the handle been closed, for example:
if(WaitForSingleObject(hDOSProcess, 100) != WAIT_TIMEOUT) {
  // run the DOS program again
}

The second one, never tried, but here some stuff:
Try using GetProcessTimes function to see if user and kernel times changed..
Or there are some functions like
AssignProcessToJobObject and QueryInformationJobObject, I think it does the same thing as GetProcessTimes do, but who knows...

have fun.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Gus012498Commented:
Ad1: If your dos program hangs, your hDosProcess handle will never be triggered.

Ad2: Your Dos-program still needs CPU time when it is in an infinity loop.

Regards, Gus
0
 
MelissaCAuthor Commented:
Thanks!
0
 
alechkoCommented:
You're welcome,

had you tried the second way to watch then the program hangs?
I just want to be sure it's working...
Maybe one day I'll have to use it.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now