title: My supervisor crashes when I try to start it from eshell?
body: <p>I'm very new to OTP, I'm trying to create simple example to understand supervisor behaviour:</p>
  
  <p>Here is simple increment server</p>
  
  <pre><code>-module( inc_serv ).
  -behaviour( gen_server ).
  -export( [ start/0, inc/1, stop/0 ] ).
  -export( [ init/1, handle_call/3, terminate/2 ] ).
  
  start() -&gt;
          gen_server:start_link( { local, ?MODULE }, ?MODULE, no_args, [] ).
  
  stop() -&gt;
          gen_server:call( ?MODULE, stop ).
  
  inc( Num ) -&gt;
          gen_server:call( ?MODULE, { num, Num } ).
  
  init( no_args ) -&gt;
          io:format( "~p~n", [ "Increment server started :)" ] ),
          { ok, no_state }.
  
  handle_call( { num, Num }, _From, no_state ) -&gt;
          { reply, Num + 1, no_state };
  handle_call( stop, _From, no_state ) -&gt;
          { stop, normal, ok, no_state }.
  
  terminate( Reason, no_state ) -&gt;
          io:format( "~p~n", [ "Increment server stopped" ] ).
  </code></pre>
  
  <p>And I'd like to make it supervised by this module:</p>
  
  <pre><code>-module( supervisor_inc ).
  -behaviour( supervisor ).
  
  -export( [ start/0 ] ).
  -export( [ init/1 ] ).
  
  start() -&gt;
          supervisor:start_link( { local, ?MODULE }, ?MODULE, no_args ).
  
  init( no_args ) -&gt;
          process_flag( trap_exit, true ),
          Supervisor_Spec = { one_for_one, 1, 1 },
          IncServ_Spec = {
                  inc_serv,
                  { inc_serv, start, [] },
                  permanent, 2000, worker, [ inc_serv ] },
          { ok, { Supervisor_Spec, [ IncServ_Spec ] } }.
  </code></pre>
  
  <p>After that I've performed in erlang shell next steps:</p>
  
  <pre><code>1&gt; 
  1&gt; c(inc_serv).
  {ok,inc_serv}
  2&gt; 
  2&gt; c(supervisor_inc).
  {ok,supervisor_inc}
  3&gt; 
  3&gt; supervisor_inc:start().
  "Increment server started :)"
  {ok,&lt;0.43.0&gt;}
  4&gt; 
  4&gt; inc_serv:inc( 7 ).
  8
  5&gt; inc_serv:inc( 8 ).
  9
  </code></pre>
  
  <p>After this I've tried next (as I expected I've got error):</p>
  
  <pre><code>6&gt; inc_serv:inc( bad_arg ).
  "Increment server stopped"
  "Increment server started :)"
  
  =ERROR REPORT==== 23-Aug-2012::19:32:06 ===
  ** Generic server inc_serv terminating 
  ** Last message in was {num,bad_arg}
  ** When Server state == no_state
  ** Reason for termination == 
  ** {badarith,[{inc_serv,handle_call,3,[{file,"inc_serv.erl"},{line,22}]},
                {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,588}]},
                {proc_lib,init_p_do_apply,3,
                          [{file,"proc_lib.erl"},{line,227}]}]}
  
  =ERROR REPORT==== 23-Aug-2012::19:32:06 ===
  ** Generic server supervisor_inc terminating 
  ** Last message in was {'EXIT',&lt;0.31.0&gt;,
                             {{{badarith,
                                   [{inc_serv,handle_call,3,
                                        [{file,"inc_serv.erl"},{line,22}]},
                                    {gen_server,handle_msg,5,
                                        [{file,"gen_server.erl"},{line,588}]},
                                    {proc_lib,init_p_do_apply,3,
                                        [{file,"proc_lib.erl"},{line,227}]}]},
                               {gen_server,call,[inc_serv,{num,bad_arg}]}},
                              [{gen_server,call,2,
                                   [{file,"gen_server.erl"},{line,180}]},
                               {erl_eval,do_apply,6,
                                   [{file,"erl_eval.erl"},{line,576}]},
                               {shell,exprs,7,[{file,"shell.erl"},{line,668}]},
                               {shell,eval_exprs,7,
                                   [{file,"shell.erl"},{line,623}]},
                               {shell,eval_loop,3,
                                   [{file,"shell.erl"},{line,608}]}]}}
  ** When Server state == {state,
                              {local,supervisor_inc},
                              one_for_one,
                              [{child,&lt;0.48.0&gt;,inc_serv,
                                   {inc_serv,start,[]},
                                   permanent,2000,worker,
                                   [inc_serv]}],
                              undefined,1,1,
                              [{1345,739526,107495}],
                              supervisor_inc,no_args}
  ** Reason for termination == 
  ** {{{badarith,[{inc_serv,handle_call,3,[{file,"inc_serv.erl"},{line,22}]},
                  {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,588}]},
                  {proc_lib,init_p_do_apply,3,
                            [{file,"proc_lib.erl"},{line,227}]}]},
       {gen_server,call,[inc_serv,{num,bad_arg}]}},
      [{gen_server,call,2,[{file,"gen_server.erl"},{line,180}]},
       {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,576}]},
       {shell,exprs,7,[{file,"shell.erl"},{line,668}]},
       {shell,eval_exprs,7,[{file,"shell.erl"},{line,623}]},
       {shell,eval_loop,3,[{file,"shell.erl"},{line,608}]}]}
  ** exception exit: {{badarith,[{inc_serv,handle_call,3,
                                           [{file,"inc_serv.erl"},{line,22}]},
                                 {gen_server,handle_msg,5,
                                             [{file,"gen_server.erl"},{line,588}]},
                                 {proc_lib,init_p_do_apply,3,
                                           [{file,"proc_lib.erl"},{line,227}]}]},
                      {gen_server,call,[inc_serv,{num,bad_arg}]}}
       in function  gen_server:call/2 (gen_server.erl, line 180)
  </code></pre>
  
  <p>After this I've expected - my supervisor to restart <code>inc_serv</code>. But it didn't:</p>
  
  <pre><code>7&gt; inc_serv:inc( 8 ).      
  ** exception exit: {noproc,{gen_server,call,[inc_serv,{num,8}]}}
       in function  gen_server:call/2 (gen_server.erl, line 180)
  </code></pre>
  
  <p>Could you help me to understand what happened? And how should I rewrite my supervisor, to make it able to restart <code>inc_serv</code></p>
  
  <p>Thanks</p>