I have an Erlang supervisor that supervises a process of a worker-server based on gen_server, I start form the shell my supervisor, which in turn starts my worker-server with no problems, It looks like this:
start_link() ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, []).
But I when I crash my worker server, my supervisor crashes with it for unknown reason.
I found on the internet a fix for this, I use this:
start_link_shell() ->
    {ok,Pid} = supervisor:start_link({local, ?SERVER}, ?MODULE, []),
    unlink(Pid).
Now it works fine, but I don't understand why, Can anyone explain ?
**
Update
**
This is my init function
%%%===================================================================
init([]) ->
    % Building Supervisor specifications
    RestartStrategy = one_for_one,
    MaxRestarts = 2,
    MaxSecondsBetweenRestarts = 5000,
    SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
    % Building Child specifications
    Restart = permanent,
    Shutdown = 2000,    % Number of seconds the child is allowed to run after receiving shutdown message
    Type = worker,
    ChildSpec = {'db_server', 
                {'db_server', start_link, []},
                Restart, 
                Shutdown, 
                Type, 
                ['db_server']},
    % Putting Supervisor and Child(ren) specifications in the return
    {ok, {SupFlags, [ChildSpec]}}.