garrison
Resolve the pid of a remote registered process?
Alright, the actual use-case here is far too cursed to explain, but I wanted to call Process.exit/2 on a remote registered name. For a local registered name I can use Process.whereis/1 to get the pid and then send it the exit signal, but there is no whereis({name, node}) function as far as I can tell.
The send/2 function accepts the pid or {name, node} tuple directly, which makes me think what actually happens is that Erlang sends the message directly to the node to be resolved in one round-trip, which makes sense. I assume that’s also why send({name, node}) cannot raise while send(name) raises for an unregistered name (which is inconsistent with the rest of OTP and kinda bizarre).
But then exit/2 does not accept {name, node} tuples, so there’s no way to send an exit signal across the network without a remote pid. But I can’t find any way to resolve a remote name to a pid!
GenServer.whereis({name, node}) literally just returns {name, node}, which again makes sense because why would you want to eat a round-trip resolving the name.
This seems like a bit of a weird hole in OTP. I guess sending exit signals to registered processes through distribution just never comes up in practice?
To be clear I am not really looking for a solution here, this is not a serious problem. I’m just wondering if anyone knows of a “blessed” way to kill a process on another node by name. You know, for science ![]()
Most Liked
LostKobrakai
You could probably (e)rpc the job of sending the exit signal to the node.
ausimian
With some caveats, the canonical way to do this in a fully connected Erlang cluster is to use global, register your process with {global, <name>} and use global:whereis_name/1.







