[erlang-questions] dumb question from rookie

envelopes envelopes sunwood360@REDACTED
Tue Mar 6 07:07:15 CET 2012


I have a sample program generated from rebar

1. mysample_app.erl

-module(mysample_app).

-behaviour(application).

%% Application callbacks
-export([start/2, stop/1, main/1]).

%% ===================================================================
%% Application callbacks
%% ===================================================================

start(_StartType, _StartArgs) ->
    mysample_sup:start_link().

stop(_State) ->
    ok.


main([A]) ->
I = list_to_integer(atom_to_list(A)),
F = fac(I),
io:format("factorial ~w = ~w~n" ,[I, F]),
init:stop().
fac(0) -> 1;
fac(N) -> N*fac(N-1).


2. mysample_sup.erl


-module(mysample_sup).

-behaviour(supervisor).

%% API
-export([start_link/0]).

%% Supervisor callbacks
-export([init/1]).

%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type,
[I]}).

%% ===================================================================
%% API functions
%% ===================================================================

start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

%% ===================================================================
%% Supervisor callbacks
%% ===================================================================

init([]) ->
    {ok, { {one_for_one, 5, 10}, []} }.


3) the problem.
erl -pa ebin -s mysample_app main 23  ===> worked fine
erl -pa ebin -s mysample_app start   ===> crashed on boot.

{"init terminating in
do_boot",{undef,[{mysample_app,start,[],[]},{init,start_it
,1,[{file,"init.erl"},{line,1042}]},{init,start_em,1,[{file,"init.erl"},{line,10
22}]}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

what is the cause ? my erlang is the latest R15.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120305/4f22cab7/attachment.htm>


More information about the erlang-questions mailing list