<div>Hi,</div>
<div> </div>
<div>If you're using a gen_server, you can also use start_link/4 or start/4 with a first argument of {local, Name} or {global, Name} and the details will be handled for you.</div>
<div> </div>
<div>If it's a server you implement yourself, do this:</div>
<div> </div>
<div>start() -><br> spawn(?MODULE, init, []).</div>
<div> </div>
<div>init() -></div>
<div> case (catch register(test_server, self()) of</div>
<div> {'EXIT', _} -></div>
<div> already_registered; % process ends here</div>
<div> _ -></div>
<div> load_accounts()</div>
<div> end.</div>
<div> </div>
<div>From the shell you can send test_server ! Msg, which will find either the newly spawned process or the older one that was running.</div>
<div> </div>
<div>In your code, already_registered isn't returned from the function, so the value is lost</div>
<div>The return is the value of "Pid ! exit", which is the atom 'exit'.</div>
<div> </div>
<div> already_registered,<br>%% io:format(" test_server:already<br>registered:~p~n",[Err]),<br> %% Kill spawned process, via msg<br> Pid ! exit;
<br> </div>
<div>hope this helps,</div>
<div>/Vlad</div>
<div> </div>