2
-behaviour(application).
4
-define(SUP,deadlock_sup).
5
-define(CHILD,deadlock_child).
8
%%%-----------------------------------------------------------------
9
%%% application callbacks
10
start(_StartType, _StartArgs) ->
11
supervisor:start_link({local, ?SUP}, ?MODULE, [sup]).
18
%%%-----------------------------------------------------------------
19
%%% supervisor callbacks
21
{ok, {{one_for_one, 5, 10}, [
23
sasl_syslog_dm, {?MODULE, start_link, []},
24
permanent, brutal_kill, worker,
30
%%%-----------------------------------------------------------------
31
%%% gen_server callbacks
33
case application:get_env(deadlock, fail_start) of
35
%% we must not fail on the first init, otherwise supervisor
36
%% terminates immediately
39
timer:sleep(infinity), % init hangs!!!!
43
handle_call(_Req, _From, State) ->
46
handle_cast(restart, State) ->
49
handle_info(_Msg, State) ->
52
terminate(_Reason, _State) ->
55
code_change(_OldVsn, State, _Extra) ->
59
%%%-----------------------------------------------------------------
62
gen_server:start_link({local, ?CHILD}, ?MODULE, [child], []).
65
%%%-----------------------------------------------------------------
68
application:set_env(deadlock, fail_start, true), % next init will hang
69
gen_server:cast(?CHILD, restart).