Error in Supervisor model

Lennart Ohman <>
Mon Jan 9 15:08:32 CET 2006


Hi, hmm, how actually do you start "this" little example of
yours?
The reason for my suspisiousnes is that your childrenspecification
seems wrong. If you look in the man-page for supervisor.erl you
find that a childrenspecification is a list of the following tuple:

child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}
 Id = term()
 StartFunc = {M,F,A}
  M = F = atom()
  A = [term()]
 Restart = permanent | transient | temporary
 Shutdown = brutal_kill | int()>=0 | infinity
 Type = worker | supervisor
 Modules = [Module] | dynamic
  Module = atom()

In your example it is just a list.

Second:

The example gen_fsm which do not crash, according to you,
can never initialize.
Who ever calls test:start/0 will never get a return value.
"He" will infact instead "become" a never ending loop, since
you have a call to loop/0 last in the start/0 function.


I suggest you study and try out a few of the examples in:

http://www.erlang.se/doc/doc-5.4.12/doc/design_principles/part_frame.html

where you will find examples of both gen_fsm and supervisors
you can copy and modify to experiment with.

Good luck,
Lennart


-------------------------------------------------------------
Lennart Ohman                   office  : +46-8-587 623 27
Sjoland & Thyselius Telecom AB  cellular: +46-70-552 67 35
Sehlstedtsgatan 6               fax     : +46-8-667 82 30
SE-115 28, STOCKHOLM, SWEDEN    email   : 
-----Original Message-----
From: 
[mailto:] On Behalf Of Surindar Sivanesan
Sent: Monday, January 09, 2006 1:18 PM
To: 
Subject: Error in Supervisor model

Im new to OTP.When i start the supervisor, while it is creating child,
it encounter error and the supervisor exit.Please give me the reason
why this happens,Also give me the solutuon to this problem

The supervisor code is

-module(super).
-compile(export_all).
-behaviour(supervisor).

start()->
	supervisor:start_link({local,head},?MODULE,[]),
		
init(Any)->
         {ok,{
              {one_for_one,1,60},
               [test,{test,start,[]},permanent,brutal_kill,worker ,[test]}
               ]
               }
          }.


The child code is


-module(test).
-compile(export_all).
-behaviour(gen_fsm).

start()->
	gen_fsm:start_link({local,name},test,[],[]).
	
init(A)->
	{ok,free,[]}.

But if i do the same coding with one loop in the child, the supervisor
is not exiting.
The child code is

module(test).
-compile(export_all).
-behaviour(gen_fsm).

start()->
	gen_fsm:start_link({local,name},test,[],[]),
                 loop().
	
init(A)->
	{ok,free,[]}.

loop()->
   loop().

Please clarify this
--
with regards,
S.Surindar





More information about the erlang-questions mailing list