The erlang process PID reference is returned from processes that are initiated in the form of such as :
<0.344.0>
Having such PID, how can you extract its three parts, serialized it and later recompose them ?
In my example I would like to have:
{A,B,C} = decomposePid(Pid),
% serialize somewhere
% deserialize somewhere
Pid = recompose(A,B,C),
I understand that the Pid can be sent around, as parameters, etc, but I have serialization needs that need to really decouple those A,B,C values out of the Pid.
Or use erlang:term_to_binary/1 and erlang:binary_to_term/1. It depends on what you intend to do with the serialized pid. Serializing it with pid_to_list and list_to_pid results in something which is only valid in that erlang node while using term_to_binary and binary_to_term is valid in a distributed erlng system. However, in both cases the serialized pid is only valid as long as the original erlang node is running, once it terminates the serialized pid is meaningless as the process to which it referred has disappeared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With