Closed aberman closed 12 years ago
Well, actually, it's the shell process that dies. The gproc processes remain unaffected, since the subscribe/2 function only registers a property (a process-local operation). The gproc API rather consistently enforces that trying to register the same entity twice raises an exception. However, this should of course be documented in gproc_ps:subscribe/2.
The following shell interaction illustrates that it's the shell process that dies.
$ erl
Erlang R15B (erts-5.9) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9 (abort with ^G)
1> application:start(gproc).
ok
2> regs().
...
gproc <0.37.0> gproc:init/1 30 0
gproc_bcast <0.39.0> gproc_bcast:init/1 26 0
gproc_monitor <0.38.0> gproc_monitor:init/1 28 0
gproc_sup <0.36.0> supervisor:gproc_sup/1 961 0
...
3> self().
<0.31.0>
4> gproc_ps:subscribe(l,test).
true
5> gproc_ps:subscribe(l,test).
** exception error: bad argument
in function gproc:reg/1
called as gproc:reg({p,l,{gproc_ps_event,test}})
6> self().
<0.44.0>
7> regs().
...
gproc <0.37.0> gproc:init/1 55 0
gproc_bcast <0.39.0> gproc_bcast:init/1 26 0
gproc_monitor <0.38.0> gproc_monitor:init/1 28 0
gproc_sup <0.36.0> supervisor:gproc_sup/1 961 0
...
Ah, ok, in that case I guess you can close this issue then unless you want it to remind you to document the exception. Thanks @uwiger !
Docs updated.
Result: gproc crashes and you see an error:
\ exception error: bad argument in function gproc:reg/1 called as gproc:reg({p,l,{gproc_ps_event,test}})
The supervisor does start the process again, and if you type the subscribe again, you'll get 'true' returned.
Expected result: A tuple like {error, already_subscribed}, should be returned and the gproc process should not die.