loading a table from file doesn't work unless inside erl shell

Erik Garrison garris@REDACTED
Sun Apr 30 23:04:06 CEST 2006



> Matthias Lang wrote:
>
> > Can you run 'hello world' from bash? If you can do that, then you can
> > do anything, i.e. there's nothing special about ets. Here's an
> > example:
> >
> > Here's hello world:
> >
> >    -module(hw).
> >    -export([go/1]).
> >
> >    go(X) ->
> >       io:fwrite("Hello world. My arguments are ~p\n", [X]).

This wasn't my problem, but the effort and psychological divination are
greatly appreciated!  I'll be more clear in the future.  (Good to know
that things are *fully* generalized in terms of what you can do from
bash.)


On Sun, 30 Apr 2006, Claes Wikstrom wrote:

>
> Except that the process owning the ets table must
> continue to live. When an ets-owning process dies, all ets
> tables created by the process dies.
>
> Thus:
>
> go(File) ->
>     spawn(fun() ->
>             ets:file2tab(File),
>             timer:sleep(infinity)
>           end).
>

This is exactly the problem.  When I run the program from the Erlang
shell, I run an initializing function which starts up the simulation,
loads the ets table state from file, etc.  This function then ends.

In this case, the owning process is the shell itself, so everything is
groovy.  However, when I run it from the bash shell, I get an immediate
error because the startup process dies.

Subsequent trials agree.

-Erik



More information about the erlang-questions mailing list