[erlisp-devel] Process linking

Patrick D. Logan patrickdlogan at stardecisions.com
Mon Aug 22 23:31:06 UTC 2005


>> A parent process won't die when a child dies unless they are
>> /linked/, as far as I know.  It's links that determine process
>> deaths, not who spawned who.

Yes, they have to be explicitly linked.

> Should it also be possible to link processes which do not have a
> parent-child relationship? 

Yes, links are not just parent-child. See...

http://erlang.org/course/error_handling.html#layer

Also links in Erlang are two-way...

> Are links two-way...

> If a process dies, is it possible that kill signals will be sent to
> more than one linked process at a time, or is there ordinarily just
> one linked process that would be affected?

There could be multiple. (A perhaps-obvious-to-most note: these are
not OS kill signals. I'm not sure how familiar people are here with
Erlang's lightweight processes.)

>> Also, there's a flag to choose what will happen when a linked
>> process dies.  Either the receiving process dies too (which could
>> in turn cause other linked processes to die), or it gets a message
>> in its mailbox, which it can then handle any way it pleases just
>> like every other kind of message.
>
> Providing two behaviors, kill or send message, doesn't sound too
> hard.  I think I will start by implementing the send message
> version, then modify it to respond to such a flag. Of course,
> getting to the point of providing even one of those behaviors could
> be tricky.

My understanding of Erlang's internals is a bit fuzzy so some of this
is may be incorrect: Each node has a kind of process monitor. Each
process in the node has a mailbox. Communication between nodes
essentially occurs at the node level (which cuts down the number of
real connections a good bit.) When a connection is lost between nodes
(and perhaps cannot be re-established reasonably), any linked
processes will be killed by the process monitor or the process monitor
will put a message in the process' mailbox if that is the nature of
the link.

Likewise if a process exits but the node and connection are ok, then
the process monitor would send word of this to the linked
processes. Then the behavior above kicks in just as in the lost
connection case.

-Patrick


More information about the Erlisp-devel mailing list