[erlang-questions] Why does this crash?

Vimal Kumar vimal7370@REDACTED
Sun Sep 27 12:28:16 CEST 2015

Hi Jesper,

I now implemented supervision trees along with the application controller,
and things now work as it should be.

1> application:start(mybank).

2> whereis(bank_server).

3> bank_server:new_user(user1, "d3fault").

4> {_, UniqueId} = bank_server:login(user1, "d3fault").

5> bank_server:new_user(user2, "d3fault").

6> {_, UniqueId} = bank_server:login(user2, "d3fault").
** exception error: no match of right hand side value {ok,

7> whereis(bank_server).

Unlinking the process is a great tip for testing from shell, didn't cross
my mind.


On Sun, Sep 27, 2015 at 3:24 PM, Jesper Louis Andersen <
jesper.louis.andersen@REDACTED> wrote:

> On Sun, Sep 27, 2015 at 10:52 AM, Vimal Kumar <vimal7370@REDACTED> wrote:
>> Going to add supervisors into this system and learn more about it.
> It doesn't happen in real systems, because the supervision trees are
> linked to the application controller, and not the shell. If you simply add
> a supervision tree, and link that tree to the shell, you are usually not
> free of the problem.
> When developing however, you can unlink the pid:
> {ok, P} = foo:start_link().
> unlink(P).
> which will have P not die if the shell does.
> The other resources to look out for are ETS tables, and port()'s, that is
> network sockets and files. If their controlling process, i.e. the shell,
> goes away, then that resource is cleaned/reaped/closed again.
> --
> J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150927/1c524f1a/attachment.htm>

More information about the erlang-questions mailing list