如何自杀控制台应用程序? [英] How to suicide a console app?

查看:224
本文介绍了如何自杀控制台应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制台应用程序创建/启动其他子进程。我需要检查自己是否自己或他的ProcessChilds进入死锁,并杀死最小的相关联的进程树。

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.

有了这个目标,他的进程childs,可能有相同的递归算法。

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?

当然,我可以使用该文件的持久文件和WatchDog / KeepAliveLook,当它不再存在时,他们这样做(自杀),但我相信有一个更干净

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.

推荐答案

我将使用一些进程间通信的方法(远程,WCF,命名管道,窗口事件,DDE等)发送通知到吃药丸。更大的问题是你为什么设计这样?听起来有点古老和古老的建筑。

I would use some method of inter-proccess communication (remoting, WCF, named pipes, window events, DDE, etc) to send the notification to "eat a poison pill". The bigger question is why are you designing this as such? Sounds a bit archaic and antiquated architecture.

这篇关于如何自杀控制台应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆