time it takes to reastart gen_server

Dietmar Schaefer dietmar@REDACTED
Tue Jan 3 12:46:48 CET 2006


Happy new year !


I am trying to develop a gen_server which starts a unix process


do(ExtPrg) -> 
    process_flag(trap_exit, true),                           %% to get 
informed when process terminates
    Port = open_port({spawn, ExtPrg}, [{packet, 2}]),        %% ExtProg 
also includes parameter
    loop(Port).



loop(Port) ->
    receive
    {'EXIT',Port,Reason}   ->   io:format("external program exited~n 
Reason=~p Port=~p~n",[Reason,Port]),    %port program died
                    gen_server:call(self(),stop)   %% all work is done - 
go home
    end.



   
This gen_server is supervised by a  supervisor.

init(_Args) ->   
    case  whereis(watchdog) of
    undefined ->                    %% register only once
     register(watchdog, self());
    _ -> ok
    end,


Xclock = {xclock,{xclock,start_link,["/usr/X11R6/bin/xclock"]},
      permanent,brutal_kill,worker,[xclock]},

Xterm =  {xterm,{xterm,start_link,["/usr/bin/xterm"]},
       permanent,brutal_kill,worker,[xterm]},

    {ok,{{one_for_one,1,6}, [Xclock,Xterm]}}.


It takes 5 seconds to restart my xclock after I closed it.

How can I fasten it up ?

regards


Dietmar



More information about the erlang-questions mailing list