[erlang-questions] How to get pid number in NIF code?

Jovi Zhang bookjovi@REDACTED
Wed Sep 28 11:04:20 CEST 2011


On Wed, Sep 28, 2011 at 4:48 PM, Tony Rogvall <tony@REDACTED> wrote:
> I do not think there is a way to extract that number (except for a small
> hack, of course)
> Care to tell the reason behind why you need it ?
> /Tony
>

Hmm, I'm writing a NIF library to let erlang process communicate with
external hand. we call that as "hand", it is similar with erlang
process, but with different number reference, hand is range from
0-65535.

So in this NIF library I must remember the mapping of
"process<->hand", actually I only run this in one node, with process
like <0.X.0>,
which I only care about process number, that's why I want to get
process number, not whole pid structure.

Of course I can store all "ErlNifPid<->hand index", but that will
consume a lot of memory.

I think erts should provide API or macro for get process number for
some use case.



More information about the erlang-questions mailing list