[英]Design idea on how to make a watchdog program to be aware and handle an exit code of one of it's wards
In my project, I have a several applications running. 在我的项目中,我有几个正在运行的应用程序。
One of them is a 'watchdog' application - an application that checks every time interval in an infinite loop weather the other applications (wards) are still running. 其中一个是“看门狗”应用程序-该应用程序检查无限循环中每个时间间隔的其他应用程序(病房)是否仍在运行。 In case a ward is no longer running - the watchdog restarts it.
万一病房不再运行-看门狗会重新启动它。
I now want to extend functionality of the watchdog so that he will somehow become aware not only if a program stops running, but what exit code it returned when it did, and then act according to exit code. 我现在想扩展看门狗的功能,以便他不仅可以知道程序是否停止运行,还可以知道程序退出时返回的退出代码,然后根据退出代码采取行动。
You should already be checking whether the ward has terminated with a wait function like WaitForMultipleObjects
, called on a handle to the ward process (which you acquired via CreateProcess
or OpenProcess
). 您应该已经在检查病房是否已使用诸如
WaitForMultipleObjects
类的等待函数终止,该函数在病房进程的句柄上调用(您通过CreateProcess
或OpenProcess
获取)。 Once you've detected a terminated process, pass that same process handle to GetExitCodeProcess
and it will tell you the exit code. 一旦检测到终止的进程,请将相同的进程句柄传递给
GetExitCodeProcess
,它将告诉您退出代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.