[erlang-questions] gen_server & trap_exit
Per Melin
per.melin@REDACTED
Sat Apr 9 15:18:14 CEST 2011
On Sat, Apr 9, 2011 at 2:27 PM, Roberto Ostinelli <roberto@REDACTED> wrote:
> 12>abc().
> ** exception error: undefined shell command abc/0
>
> =ERROR REPORT==== 9-Apr-2011::14:16:51 ===
> ** Generic server testserver terminating
> ** Last message in was {'EXIT',<0.272.0>,
> {{shell_undef,abc,0},
> [{shell,shell_undef,2},
> {erl_eval,local_func,5},
> {shell,exprs,7},
> {shell,eval_exprs,7},
> {shell,eval_loop,3}]}}
>
> I believe that this behavior of the server exiting because its parent exits
> is supposed to happen, since trap_exit doesn't let the gen_server trap its
> parent process exiting. What I believe happens is that the shell 'crashes'
> and so does the child process 'testserver'.
1> self().
<0.31.0>
2> 1 = 2.
** exception error: no match of right hand side value 2
3> self().
<0.34.0>
So, yes, the process for your shell session dies, and since that is
the process that started your server, it goes down too.
You can change this behavior of the shell:
1> self().
<0.31.0>
2> catch_exception(true).
false
3> 1 = 2.
* exception error: no match of right hand side value 2
4> self().
<0.31.0>
More information about the erlang-questions
mailing list