[erlang-questions] Re: erl startup

Bernard Duggan bernie@REDACTED
Wed May 19 05:11:27 CEST 2010


On 19/05/10 12:59, Wes James wrote:
> Any explanation here?
>    
Yep.

My guess is that -run either spawns your function in a new process or 
(more likely) runs it in a process which subsequently exits.  That means 
that:

a) The timer will stop (since the process that launched it shut down).
b) The return value ("id_table: " ++ Id_Table) will not be printed 
(since there's no command to print it).
c) The ets table will no longer exist (since, again, the process that 
spawned it has finished and you did not specify an heir), hence the 
badarg when you try to reference it.

By contrast, when you run my_mod:start() from the shell, the shell 
process that launched it continues to run (so the timer and the ets 
table persist), and the return value is printed (as happens with any 
other function you call from the shell).

B


More information about the erlang-questions mailing list