Gen processes and exit/2 from shell

Hakan Mattsson hakan@REDACTED
Tue Dec 17 14:33:16 CET 2002

On Tue, 17 Dec 2002, Ulf Wiger wrote:

Uffe> On 17 Dec 2002, Luke Gorrie wrote:
Uffe> >It is a special case in gen_server:loop/6 that if your
Uffe> >parent process (the one that spawned you) dies then you
Uffe> >have to terminate, even if you're trapping exits. I guess
Uffe> >the intention is to use a reliable parent like a
Uffe> >supervisor, and not outlive it.
Uffe> >
Uffe> >When you use exit/2 from the shell it will get an {'EXIT',
Uffe> >ShellPid, Rsn} signal - so if ShellPid == Parent (who
Uffe> >spawned the server) then you would hit the special case.
Uffe> >
Uffe> >-Luke
Uffe> This is a really annoying feature when testing a server from
Uffe> the shell. What I usually do when playing around in the
Uffe> shell is:
Uffe> - {ok,Pid} = Server:start_link(...).
Uffe> - unlink(Pid).
Uffe> ...and then get on with the testing.
Uffe> /Uffe

That is one useful approach. Another is to create the processes,
ets-tables or whatever from one (resource owning) shell and then
create another (working) shell where you do the actual work. This has
helped me many times when I am doing my annoying typos in the shell.

(Starting a new shell is done with 'control-g' followed by 's' and 'c')


Håkan Mattsson
High Availability Software, DBMS Internals

More information about the erlang-questions mailing list