简体   繁体   English

Erlang进程监控自身

[英]Erlang process monitoring itself

I am trying to create a process in Erlang that can monitor itself and restart of it exits. 我正在尝试在Erlang中创建一个可以监视自身并重新启动它的进程。 So far I've had no luck at all, so don't have any code to show. 到目前为止,我根本没有运气,所以没有任何代码可以显示。 Is this even possible in Erlang, and if so how? 这在Erlang中是否可能,如果是这样,怎么样?

Edit: J Fritsch posted a link to a sample that monitors itself but only once. 编辑: J Fritsch发布了一个样本的链接,该样本只监视自己但只有一次。 If exit(Doctor, doctor). 如果退出(医生,医生)。 is used twice it doesn't work the second time. 使用两次它第二次不起作用。 Any ideas on how to get round this? 有关如何绕过这个的任何想法?

If the process doing the monitoring is the one doing the dying, you will invariably get yourself into knots. 如果进行监测的过程就是那个正在进行监视的过程,那么你总会陷入困境。

Use a supervisor. 使用主管。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM