trap_exit cannot trap signal when exit/1 doesn't called explicitly

Bengt Kleberg bengt.kleberg@REDACTED
Wed Aug 23 09:03:59 CEST 2006

On 2006-08-22 18:22, lang er wrote:
> demonstrate_normal() ->
>     link(whereis(demo)).
> demonstrate_exit(What) ->
>     link(whereis(demo)),
>     exit(What).

> -----------
> After start(), I call  demonstrate_normal(), demo process should trap 
> the exit(normal) signal, but it doesn't,
>  and if  I call  demonstrate_exit(normal) , demo do trap the exit(normal).
> The only difference between theses two situations is the exiting process 
> call exit/1 explicitly.
> Must I call exit before existing ?

''existing''? do you mean exiting :-)

you did not exit.
the shell is linked to the demo process when you call 
demonstrate_normal(). but the shell never exits, so there is nothing to 
trap for demo.
in demonstrate_exit() you do exit, and demo gets something.
(the shell is restarted after the exit).

    EPO guidelines 1978: "If the contribution to the known art resides
    solely in a computer program then the subject matter is not
    patentable in whatever manner it may be presented in the claims."

More information about the erlang-questions mailing list