Skip to contentSkip to conversation

Handle TIF_RESTORE_SIGMASK for i386

PATCH Oleg Nesterov 1 participant 1 message Jan 15, 2006 Scheduler

lore
Share & tools
lore
#0 lore raw
Quoted 7 lines · David Woodhouse

The attached patch handles TIF_RESTORE_SIGMASK as added by David Woodhouse's patch entitled:

[PATCH] 2/3 Add TIF_RESTORE_SIGMASK support for arch/powerpc [PATCH] 3/3 Generic sys_rt_sigsuspend

Quoted 8 lines

It does the following:

(1) Declares TIF_RESTORE_SIGMASK for i386.

(2) Invokes it over to do_signal() when TIF_RESTORE_SIGMASK is set.

(3) Makes do_signal() support TIF_RESTORE_SIGMASK, using the signal mask saved

     in current->saved_sigmask.

Imho, there is a slightly better way to do it, see the patch below.

Instead of adding TIF_RESTORE_SIGMASK we can introduce ERESTART_SIGBLOCK return value. Now,

sys_rt_sigsuspend(sigset_t *newset)

{
	current->saved_sigmask = current->blocked;
	current->blocked = newset;

	current->state = TASK_INTERRUPTIBLE;
	schedule();
	return -ERESTART_SIGBLOCK;
}

sys_pselect()

{
	...

	ret = core_sys_select();

	if (ret == -ERESTARTNOHAND)
		ret = -ERESTART_SIGBLOCK;
}

handle_signal()

{
	sigset_t *oldset; // removed from param list

	...

	oldset = &current->blocked;
	if (regs->eax == -ERESTART_SIGBLOCK)
		oldset = &current->saved_sigmask;

	...
}

Comments?

Only for illustration, but seems to work.

 include/linux/errno.h     |    1 
 include/linux/sched.h     |    2 -
 include/asm-i386/signal.h |    3 -
 arch/i386/kernel/signal.c |   73 +++++++++++++++++++++-------------------------
 4 files changed, 36 insertions(+), 43 deletions(-)
include/linux/errno.h renamed from include/linux/errno.h~1_SIGM +1 -0
@@ -11,6 +11,7 @@
 #define ERESTARTNOHAND	514	/* restart if no handler.. */
 #define ENOIOCTLCMD	515	/* No ioctl command */
 #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
+#define ERESTART_SIGBLOCK     517
 
 /* Defined for the NFSv3 protocol */
 #define EBADHANDLE	521	/* Illegal NFS file handle */
include/linux/sched.h renamed from include/linux/sched.h~1_SIGM +1 -1
@@ -799,7 +799,7 @@ struct task_struct {
 	struct signal_struct *signal;
 	struct sighand_struct *sighand;
 
-	sigset_t blocked, real_blocked;
+	sigset_t blocked, real_blocked, saved_blocked;
 	struct sigpending pending;
 
 	unsigned long sas_ss_sp;
include/asm-i386/signal.h renamed from include/asm-i386/signal.h~1_SIGM +0 -3
@@ -217,9 +217,6 @@ static __inline__ int sigfindinword(unsi
 	return word;
 }
 
-struct pt_regs;
-extern int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset));
-
 #define ptrace_signal_deliver(regs, cookie)		\
 	do {						\
 		if (current->ptrace & PT_DTRACE) {	\
arch/i386/kernel/signal.c renamed from arch/i386/kernel/signal.c~1_SIGM +34 -39

162 lines not on this page · raw message