Skip to contentSkip to conversation

Fix sa_mask and SA_NODEFER semantics for i386

PATCH New Jörn Engel 1 participant 1 message Jul 4, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix sa_mask and SA_NODEFER semantics for i386

Hi Linus!

This patch should be less to argue about.

A trivial case where code and documentation don't match. This is from man 3 sigaction:

sa_mask gives a mask of signals which should be blocked during execu- tion of the signal handler. In addition, the signal which triggered the handler will be blocked, unless the SA_NODEFER or SA_NOMASK flags are used.

In other words:
- Always block the signals from sa_mask.
- Also block the current signal, if SA_NODEFER is not set.

But without this patch, linux ignores sa_mask, when SA_NODEFER is set, so either the documentation or our implementation is wrong. Since the bsd manpage matches the linux one, I guess the code is wrong.

Jörn

Signature · 24 lines
Everything should be made as simple as possible, but not simpler.
-- Albert Einstein

--- linux-2.5.73/arch/i386/kernel/signal.c~sigmask_i386	2003-07-04 18:59:48.000000000 +0200
+++ linux-2.5.73/arch/i386/kernel/signal.c	2003-07-04 22:39:59.000000000 +0200
@@ -551,13 +551,12 @@
 	if (ka->sa.sa_flags & SA_ONESHOT)
 		ka->sa.sa_handler = SIG_DFL;
 
-	if (!(ka->sa.sa_flags & SA_NODEFER)) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
+	spin_lock_irq(&current->sighand->siglock);
+	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
+	if (!(ka->sa.sa_flags & SA_NODEFER))
 		sigaddset(&current->blocked,sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	recalc_sigpending();
+	spin_unlock_irq(&current->sighand->siglock);
 }
 
 /*