开发者

Erlang: robustness against port owner's death

What happens when the process which owns a spawned port dies and is restarted by the supervisor?

开发者_运维问答
  1. Is there a way for the old port not to die with its owner and for the new owner to "take over"?

  2. Failing that, is it possible to ensure that the spawned process terminates when its port dies?


First, notice that you don't want the port owner to die. So move any "dangerous" code out to another process and make the port owner as dumb as possible. This is error-mitigation the Erlang way. Now, if that process dies, something is really bad, so in that case it may be clever to recycle the port as well. But since we moved everything out, we are counting on that not happening.

Regarding 2, the port will send a specific message when it terminates, so you can arrange for your spawned process to gracefully detect this and terminate with it. See

http://www.erlang.org/doc/reference_manual/ports.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜