Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you link two processes in Erlang if the current process is neither one?

Tags:

erlang

It is possible to call link(pid) in Erlang to link the currently executing process to the process identified by pid. Is it possible to link a process to another if it is not currently executing?

like image 489
John Cochran Avatar asked Oct 20 '22 02:10

John Cochran


1 Answers

No, you cannot.

You can only link/unlink from a current process to another one. If the other process is not alive, you will get a noproc error (if you are trapping exits) or receive an exit signal (if you are not trapping exits or if the other process was on another node).

You can also use spawn_link to spawn and link in one atomic operation.

like image 145
Adam Lindberg Avatar answered Oct 22 '22 21:10

Adam Lindberg