2 つの gen_server モジュールがあります。
最初のserv.erl
-module(serv).
-behaviour(gen_server).
-export([init/1, 
     handle_call/3,
     handle_cast/2, 
     handle_info/2,
     code_change/3,
     terminate/2,
     start_link/0
    ]).
start_link() ->
    gen_server:start_link(?MODULE, [], []).
init([]) ->
    process_flag(trap_exit, true),
    spawn_link(user, start_link,[]),
    {ok, []}.
handle_call(_E, _From, State) ->
        {noreply, State}.
handle_cast(_Message, State) ->
    {noreply, State}.
terminate(_Reason, _State) ->
    ok.
handle_info(Message, State) ->
    {noreply, State}.
code_change(_OldVersion, State, _Extra) ->
    {ok, State}.
そしてuser.erl (init/1 以外は完全に同じです):
init([]) ->
     {ok, []}.
サーバーは永遠に続くと思っていました。最初のサーバーが停止すると、別のサーバーが{'EXIT', Pid, Reason}メッセージを受け取ります。
ただし、serv:start_link()でモジュールを開始すると、ユーザーモジュールは開始直後にメッセージ{'EXIT',Pid,normal} で終了します。ユーザーが死ぬのはなぜですか?