1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 1996-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20%% Description: Simulates the behaviour that a child process may have. 21%% Is used by the supervisor_SUITE test suite. 22-module(supervisor_4). 23 24-export([start_child/0, start_child/1, init/1]). 25 26-export([handle_call/3, handle_info/2, terminate/2]). 27 28start_child() -> 29 gen_server:start_link(?MODULE, undefined, []). 30 31start_child(Reason) -> 32 gen_server:start_link(?MODULE, {Reason}, []). 33 34init(Reason) -> 35 process_flag(trap_exit, true), 36 {ok, Reason}. 37 38handle_call(Req, _From, State) -> 39 {reply, Req, State}. 40 41handle_info(stop, State) -> 42 {stop, normal, State}; 43handle_info(_, State) -> 44 {noreply, State}. 45 46terminate(_, {Reason}) -> 47 exit(Reason); 48terminate(_, _) -> 49 ok. 50