Preventing multiple instances through register/2

Vlad Dumitrescu vladdu55@REDACTED
Sun May 14 19:47:11 CEST 2006


Hi,

spawn the server and let it register itself in the initialization part. If
the name is already taken, just exit.

regards,
Vlad


On 5/14/06, Jeff Crane <jefcrane@REDACTED> wrote:
>
> %%Start gen_server()
> start()->
>        %% greeting msg
>        io:format(" Started test_server on:~p~n",[self()]),
>
>        %% read user/pass
>        case(
>                catch register(test_server,spawn(?MODULE,
> load_accounts, []))
>        ) of
>                {'EXIT', _} ->
>                        already_started;
>                Pid ->
>                        ok
>        end.
> ---
>
> Yes it gets caught, but it also still spawns! What's
> the proper way to prevent a duplicate spawn if not
> through case catch register(spawn) ?
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060514/6cfd376e/attachment.htm>


More information about the erlang-questions mailing list