[erlang-bugs] Fwd: exit(self(), normal) causes calling process to exit

Patrik Nyblom <>
Thu Nov 29 19:10:02 CET 2012


On 11/28/2012 08:50 PM, Daniel Luna wrote:
> I withdraw my comment.  It's still true that it works when trapping
> exits, but apparently you shouldn't have to.
>
>  From the docs:
>
> "If Reason is the atom normal, Pid will not exit."
>
> I call bug on this.
I agree. It's in the pipe.
>
> Cheers,
>
> Daniel

Cheers,
/Patrik
>
> On 28 November 2012 13:07, Daniel Luna <> wrote:
>> I replied on StackOverflow, but the gist of the problem is that you
>> don't trap exits.
>>
>> 1> self().
>> <0.32.0>
>> 2> process_flag(trap_exit, true).
>> false
>> 3> exit(self(), normal).
>> true
>> 4> self().
>> <0.32.0>
>> 5> flush().
>> Shell got {'EXIT',<0.32.0>,normal}
>> ok
>>
>> Cheers,
>>
>> Daniel
>>
>> On 28 November 2012 11:50, Stavros Aronis <> wrote:
>>> After some speculation on stackoverflow I think I will report this here as
>>> well. (I am directly copying the content of the question.)
>>>
>>> I am playing around with the exit/2 function and its behavior when self() is
>>> used as a Pid and normal as a Reason.
>>>
>>> Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:8:8] [async-threads:0]
>>> [hipe] [kernel-poll:false]
>>>
>>> Eshell V5.9.3  (abort with ^G)
>>> 1> self().
>>> <0.32.0>
>>> 2> exit(self(), normal).
>>> ** exception exit: normal
>>> 3> self().
>>> <0.35.0>
>>>
>>> Shouldn't it be the case that only a 'normal' exit message is sent to the
>>> shell process, so there is no reason to exit?
>>>
>>> Similarly:
>>>
>>> 4> spawn(fun() -> receive Pid -> Pid ! ok end end).
>>> <0.38.0>
>>> 5> exit(v(4), normal).
>>> true
>>> 6> v(4) ! self().
>>> <0.35.0>
>>> 7> flush().
>>> Shell got ok
>>> ok
>>>
>>> But:
>>>
>>> 8> spawn(fun() -> exit(self(), normal), receive _ -> ok end end).
>>> <0.43.0>
>>> 9> is_process_alive(v(8)).
>>> false
>>>
>>>
>>> _______________________________________________
>>> erlang-bugs mailing list
>>> 
>>> http://erlang.org/mailman/listinfo/erlang-bugs
>>>
> _______________________________________________
> erlang-bugs mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-bugs



More information about the erlang-bugs mailing list