Erlang: resistance to the death of the port owner

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

  • Is there a way for the old port not to die with its owner and for the new owner to "take over"?

  • Otherwise, is it possible to guarantee that the spawned process terminates when its port dies?

+6
erlang erlang-ports
source share
1 answer

First, note that you do not want the port owner to die. Therefore, move any "dangerous" code to another process and make the port owner as stupid as possible. This is error correction along the Erlang path. Now, if this process dies, something is really bad, so in this case it may be wise to recycle the port. But since we have moved everything, we expect that this will not happen.

Regarding port 2, it will send a specific message when it ends, so you can organize for your child process to correctly detect this and terminate with it. Cm

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

+5
source share

All Articles