[erlang-questions] Some problem abount exit signal?

Frédéric Trottier-Hébert fred.hebert@REDACTED
Sun Dec 5 04:02:11 CET 2010



--
Fred Hébert
http://www.erlang-solutions.com




On 2010-12-04, at 20:36 PM, Robert Virding wrote:

> Yes, this is how it works, but I definitely consider this to be a bug. To elaborate with a simple example:
> 
> 1> self().
> <0.31.0>
> 2> spawn_link(fun () -> exit(kill) end).
> ** exception exit: killed
> 3> self().
> <0.35.0>
> 
> Here I have received 'kill' signal and died as I should. Now I trap exits:
> 
> 4> process_flag(trap_exit, true).
> false
> 5> spawn_link(fun () -> exit(kill) end).
> <0.39.0>
> 6> flush().
> Shell got {'EXIT',<0.39.0>,kill}
> ok
> 
> This time I received a trappable 'kill' signal. Finally I explicitly send the 'kill' signal to me:
> 
> 7> Self = self().
> <0.35.0>
> 8> process_flag(trap_exit, true).          %Just to be explicit
> true
> 9> spawn_link(fun () -> exit(Self, kill) end).
> ** exception exit: killed
> 10> self().                                    
> <0.45.0>
> 
> And this time I received an untrappable 'kill' signal.
> 
> This means that there are two different types of 'kill' signals, trappable and untrappable, in the systems depending on how they were sent. This is illogical and unclear as there should not be two different signals with the same name which behave differently. It is definitely a bug which should be fixed. I see two (three) different solutions:
> 
> 1. Make it so that a process which does exit(kill) sends a real, untrappable kill signal to its link set (which then in turn transmit 'killed').
> 
> 2. Make it so that a process which does exit(kill) behaves as if it were killed and so transmits 'killed' to its link set.
> 
> 3. Leave it as it is and create a 'properly_behaving_really_untrappable_kill' signal which behaves sensibly.
> 
> I think the first option is the best.
> 
> Robert
> 
> P.S. Now to copy all this to erlang-bugs.

I'm not sure this can entirely be a bug. See the following: 

1> catch exit(hah).
{'EXIT',hah}
2> catch exit(self(), hah).
** exception exit: hah

In this case, exit/1 is trappable, while exit/2 is not. They already behave differently depending on whether they are 'internal' (exit/1) or 'external' (exit/2). I don't see it as too extravagant to have one kind of kill behaving differently than the other in that context.
 
> 
> P.P.S. I have just noticed that doing exit(self(), normal) kills me while some other process doing exit(Me, normal) doesn't. Sigh, so normal isn't normal.
> 
That one I would definitely consider a bug though. 



More information about the erlang-questions mailing list