[erlang-questions] Erlang shell, process dictionary & rand:seed

Raimo Niskanen <>
Thu Jan 12 09:41:35 CET 2017


On Wed, Jan 11, 2017 at 02:30:56PM -0800, nato wrote:
> In the Erlang shell, I noticed that `rand:seed/n` set my
> shell process dictionary value with the seed
> (looked at it with `process_info(self())`).
> 
> When I crashed my shell process with `1 / 0`, my new
> shell process inherited the old process's process dictionary
> value (those seed integers).
> 
> Is this expected? Is this just an aid for just the shell? And if not,
> what can I expect for non-shell processes with the above
> interplay?


It is a shell feature.

Notice below - an "** exception error:" is different from
"*** Shell process terminated! ***".  1/0 is as well as most other
exceptions is caught by the evaluator so the process will not exit.



Erlang/OTP 17 [erts-6.4.1.2] [source] [64-bit] [smp:8:8] [async-threads:10]
[hipe] [kernel-poll:false]

Eshell V6.4.1.2  (abort with ^G)
1> 1/0.
** exception error: an error occurred when evaluating an arithmetic
expression
     in operator  '/'/2
        called as 1 / 0
2> exit().
*** Shell process terminated! ***
Eshell V6.4.1.2  (abort with ^G)
1> put(a, 1).
undefined
2> get().
[{a,1}]
3> 1/0.
** exception error: an error occurred when evaluating an arithmetic
expression
     in operator  '/'/2
        called as 1 / 0
4> get().
[{a,1}]
5> exit().
*** Shell process terminated! ***
Eshell V6.4.1.2  (abort with ^G)
1> get().
[]
2> 


-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list