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

Bengt Kleberg bengt.kleberg@REDACTED
Sun Dec 2 09:13:57 CET 2012


Greetings,

Is not '!' used for sending signals (and other stuff)?

Bengt

Sent from Moxier Mail
(http://www.moxier.com)


----- Ursprungligt meddelande -----
Från: Robert Virding <robert.virding@REDACTED>
Till: Patrik Nyblom <pan@REDACTED>
Kopia: "erlang-bugs@REDACTED" <erlang-bugs@REDACTED>
Skickat: 02-12-2012 3:14 fm
Ämne: Re: [erlang-bugs] Fwd: exit(self(), normal) causes calling process to exit



Just to say that I concur that this is definitely a bug, exit/2 always sends a signal, even if the process is sending to itself, and that signal is to be treated in the same way irrespective of who sent it. Unfortunately the bug has been there a long time.

In retrospect it would might have been better to call it signal/2 instead.

Robert

----- Original Message -----
> From: "Patrik Nyblom" <pan@REDACTED>
> To: erlang-bugs@REDACTED
> Sent: Thursday, 29 November, 2012 7:10:02 PM
> Subject: Re: [erlang-bugs] Fwd: exit(self(), normal) causes calling process to exit
>
> 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 <daniel@REDACTED> 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 <aronisstav@REDACTED>
> >> 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
> >>> erlang-bugs@REDACTED
> >>> http://erlang.org/mailman/listinfo/erlang-bugs
> >>>
> > _______________________________________________
> > erlang-bugs mailing list
> > erlang-bugs@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-bugs
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
_______________________________________________
erlang-bugs mailing list
erlang-bugs@REDACTED
http://erlang.org/mailman/listinfo/erlang-bugs



More information about the erlang-bugs mailing list