All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use ERESTARTNOHAND if poll() is interrupted by a signal
@ 2007-07-29 17:05 Manfred Spraul
  2007-07-30 23:35 ` Andrew Morton
  2007-07-30 23:56 ` Chris Wright
  0 siblings, 2 replies; 14+ messages in thread
From: Manfred Spraul @ 2007-07-29 17:05 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Hi Andrew,

poll() returns -EINTR if a signal is pending.
EINTR is a bad choice: it means that poll returns to user space if the
task is stopped by SIGSTOP/SIGCONT or by the freezer.
select() and ppoll() both use ERESTARTNOHAND, this avoids a return to
user space for signals that are handled by the kernel.

The patch switches poll() to ERESTARTNOHAND.
Tested with FC6. Patch against 2.6.23-rc1-mm1.

Signed-off-by: Manfred Spraul <manfred@colorfullife.com>

--- 2.6/fs/select.c	2007-07-28 20:31:51.000000000 +0200
+++ build-2.6/fs/select.c	2007-07-28 21:21:52.000000000 +0200
@@ -621,7 +621,7 @@ static int do_poll(unsigned int nfds,  s
 		if (!count) {
 			count = wait->error;
 			if (signal_pending(current))
-				count = -EINTR;
+				count = -ERESTARTNOHAND;
 		}
 		if (count || !*timeout)
 			break;
@@ -774,7 +774,7 @@ asmlinkage long sys_ppoll(struct pollfd 
 	ret = do_sys_poll(ufds, nfds, &timeout);
 
 	/* We can restart this syscall, usually */
-	if (ret == -EINTR) {
+	if (ret == -ERESTARTNOHAND) {
 		/*
 		 * Don't restore the signal mask yet. Let do_signal() deliver
 		 * the signal on the way back to userspace, before the signal
@@ -785,7 +785,6 @@ asmlinkage long sys_ppoll(struct pollfd 
 					sizeof(sigsaved));
 			set_thread_flag(TIF_RESTORE_SIGMASK);
 		}
-		ret = -ERESTARTNOHAND;
 	} else if (sigmask)
 		sigprocmask(SIG_SETMASK, &sigsaved, NULL);
 

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-08-28  9:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-29 17:05 [PATCH] Use ERESTARTNOHAND if poll() is interrupted by a signal Manfred Spraul
2007-07-30 23:35 ` Andrew Morton
2007-07-30 23:59   ` Chris Wright
2007-07-31  0:11   ` Oleg Nesterov
2007-07-31  0:18     ` Oleg Nesterov
2007-07-31 17:36       ` Chris Wright
2007-07-31 20:31   ` Manfred Spraul
2007-07-31 21:08     ` Oleg Nesterov
2007-08-04  6:39       ` [PATCH] Use ERESTART_RESTARTBLOCK if poll() is interrupted by a signal (was: Re: [PATCH] Use ERESTARTNOHAND if poll() is interrupted by a signal) Chris Wright
2007-08-04 11:07         ` Oleg Nesterov
2007-08-15 22:27           ` [PATCH take2] Use ERESTART_RESTARTBLOCK if poll() is interrupted by a signal Chris Wright
2007-08-16 15:51             ` Oleg Nesterov
2007-08-28  9:11   ` [PATCH] Use ERESTARTNOHAND " Roland McGrath
2007-07-30 23:56 ` Chris Wright

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.