• Linus Torvalds's avatar
    Prioritize synchronous signals over 'normal' signals · a27341cd
    Linus Torvalds authored
    This makes sure that we pick the synchronous signals caused by a
    processor fault over any pending regular asynchronous signals sent to
    use by [t]kill().
    
    This is not strictly required semantics, but it makes it _much_ easier
    for programs like Wine that expect to find the fault information in the
    signal stack.
    
    Without this, if a non-synchronous signal gets picked first, the delayed
    asynchronous signal will have its signal context pointing to the new
    signal invocation, rather than the instruction that caused the SIGSEGV
    or SIGBUS in the first place.
    
    This is not all that pretty, and we're discussing making the synchronous
    signals more explicit rather than have these kinds of implicit
    preferences of SIGSEGV and friends.  See for example
    
    	http://bugzilla.kernel.org/show_bug.cgi?id=15395
    
    for some of the discussion.  But in the meantime this is a simple and
    fairly straightforward work-around, and the whole
    
    	if (x & Y)
    		x &= Y;
    
    thing can be compiled into (and gcc does do it) just three instructions:
    
    	movq    %rdx, %rax
    	andl    $Y, %eax
    	cmovne  %rax, %rdx
    
    so it is at least a simple solution to a subtle issue.
    Reported-and-tested-by: default avatarPavel Vilim <wylda@volny.cz>
    Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    a27341cd
signal.c 68.1 KB