Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang: turn pid into string

Tags:

erlang

I want to turn a Pid in erlang <0.121.0> into a string, how would I do this?

Is there a way to pattern match against a Pid?

{Node, Index, Number} = <0.121.0>.
like image 767
BC00 Avatar asked Oct 22 '25 06:10

BC00


1 Answers

pid_tokens(Pid) ->
    PidStr = pid_to_list(Pid),
    PidStr1 = lists:sublist(PidStr, 2, length(PidStr)-2),
    [N, P1, P2] = [list_to_integer(T) || T <- string:tokens(PidStr1,[$.])],
    {N, P1, P2}.

Something like this may work for you. Where Pid is process id you want to match

like image 63
Vahe Yepremyan Avatar answered Oct 24 '25 00:10

Vahe Yepremyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!