[erlang-questions] gen_server & trap_exit

Roberto Ostinelli roberto@REDACTED
Sat Apr 9 14:27:47 CEST 2011


Dear list,

I start a gen_server and in the initialization i set process_flag(trap_exit,
true), obviously to allow the gen_server to catch child processes crashes.

Whenever i start this gen_server from the shell and then issue an error in
the shell, the gen_server exits too:

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'.

Am I correct in my assumptions, or am I missing a fundamental point here?

Thank you,

r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110409/2f1bb9b7/attachment.htm>


More information about the erlang-questions mailing list