[erlang-questions] Will terminate of gen_server be called in this situation?

Bin Wang wbin00@REDACTED
Thu Jul 11 09:48:50 CEST 2013


Hi, everyone

Never mind this. I do some tests and it should work. I have write some
wrong code elsewhere.

2013/7/11 Bin Wang <wbin00@REDACTED>:
> Hi,
>
> I found my terminate in gen_server is not been called in this
> situation, did I miss something?
>
> Part of the code is:
>
> handle_info(stop, State) ->
>     {stop, normal, State}.
>
> terminate(_, _) ->
>    io:format(user, "termiate~n", []).
>
> And I have set process_flag(trap_exit, true) in "init", and this
> gen_server is under a supervisor tree. It is a simple_one_for_one
> supervisor and the spec is like this, "client" here is the module
> name:
>
>     {ok, {{simple_one_for_one, 3, 10}, [{
>         client,
>         {client, start, []},
>         transient,
>         10000,
>         worker,
>         [client]
>        }
>    ]}}.
>
> When I send some info with stop to the gen_server, it did stop, but
> the terminate function is not called. Anybody have some ideas? Thanks!



More information about the erlang-questions mailing list