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
LVL 2
MelissaCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.