[erlang-questions] linked process and after clause

Ulf Wiger <>
Sat May 9 14:14:53 CEST 2009


Try/catch does not trap EXIT signals from other processes.
The only way to do that is to trap exits.

If you really want to handle EXITs in every receive clause,
perhaps you should simply use gen_server and trap exits?

In general, though, when using textbook Erlang programming
with explicit receive clauses, you'll want to make sure that your
"top-level receives" take care of unknown messages; they also
ought to handle your EXIT signals.

BR,
Ulf W

2009/5/9 Howard Yeh <>:
> Hi,
>
> Does the after clause of a try clause get executed when a linked
> process exits abnormally?
>
> Process A is linked to process B, when A exits abnormally, I want B to
> first do some cleanup, then die.
>
> I tried to wrap B's loop in a try clause, with the cleanup in the
> after clause, but that doesn't seem to be working. I don't want to use
> trap_exit because I am afraid I'd mess up somewhere and not always
> exit process B. Is there a way to do that other than checking for
> 'EXIT' everywhere B receives?
>
> Howard
>
> --
> blog: www.metacircus.com
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list