1

I have a Console App which creates/launches other sub-processes. I need to check somehow if itself or his ProcessChilds are went to deadlock, and kill the youngest of the associated process tree.

With this objective, his process childs, may have the same "kind of recursive" algorithm.

The idea is not to kill the youngest process but instead to get the youngest to suicide by command (in a sort of speak).

Is there a way I can call an async method inside the process (maybe the same method that should exist in his childs) to do that?

Well of course I could use a persistent file and a "WatchDog/KeepAliveLook" of that file and when it does not exist anymore they do it (suicide) but I'm convinced there's a cleaner way to do this.

4

2 回答 2

2

我会使用某种进程间通信方法(远程处理、WCF、命名管道、窗口事件、DDE 等)来发送通知以“吃毒丸”。更大的问题是你为什么要这样设计?听起来有点古老和过时的建筑。

于 2013-03-18T21:24:05.620 回答
0

如果一个进程完全死锁,那么你就不能使用它的任何线程。您需要(外部)在进程中创建一个新线程,这只能通过 Windows 的调试 API 来完成。

如果你想杀死一个子进程,为什么不直接杀死它而不是让它杀死自己呢?

于 2013-03-18T21:24:36.747 回答