mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@addtoit.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] UML - disable pending signals across a reboot
Date: Fri, 10 Sep 2004 14:28:16 -0400	[thread overview]
Message-ID: <200409101828.i8AISG0O003438@ccure.user-mode-linux.org> (raw)

On reboot, all signals and signal sources are disabled so that late-arriving
signals don't show up after the reboot exec, confusing the new image, which
is not expecting signals yet.

				Jeff

Index: 2.6.9-rc1/arch/um/include/irq_user.h
===================================================================
--- 2.6.9-rc1.orig/arch/um/include/irq_user.h	2004-06-16 01:19:37.000000000 -0400
+++ 2.6.9-rc1/arch/um/include/irq_user.h	2004-09-10 13:11:06.000000000 -0400
@@ -14,6 +14,7 @@
 extern void free_irq_by_fd(int fd);
 extern void reactivate_fd(int fd, int irqnum);
 extern void deactivate_fd(int fd, int irqnum);
+extern int deactivate_all_fds(void);
 extern void forward_interrupts(int pid);
 extern void init_irq_signals(int on_sigstack);
 extern void forward_ipi(int fd, int pid);
Index: 2.6.9-rc1/arch/um/include/os.h
===================================================================
--- 2.6.9-rc1.orig/arch/um/include/os.h	2004-09-09 19:46:14.000000000 -0400
+++ 2.6.9-rc1/arch/um/include/os.h	2004-09-10 13:11:06.000000000 -0400
@@ -140,6 +140,7 @@
 extern int os_file_modtime(char *file, unsigned long *modtime);
 extern int os_pipe(int *fd, int stream, int close_on_exec);
 extern int os_set_fd_async(int fd, int owner);
+extern int os_clear_fd_async(int fd);
 extern int os_set_fd_block(int fd, int blocking);
 extern int os_accept_connection(int fd);
 extern int os_create_unix_socket(char *file, int len, int close_on_exec);
Index: 2.6.9-rc1/arch/um/include/time_user.h
===================================================================
--- 2.6.9-rc1.orig/arch/um/include/time_user.h	2004-06-16 01:19:01.000000000 -0400
+++ 2.6.9-rc1/arch/um/include/time_user.h	2004-09-10 13:11:06.000000000 -0400
@@ -11,6 +11,7 @@
 extern void set_interval(int timer_type);
 extern void idle_sleep(int secs);
 extern void enable_timer(void);
+extern void disable_timer(void);
 extern unsigned long time_lock(void);
 extern void time_unlock(unsigned long);
 
Index: 2.6.9-rc1/arch/um/kernel/irq_user.c
===================================================================
--- 2.6.9-rc1.orig/arch/um/kernel/irq_user.c	2004-09-09 19:46:14.000000000 -0400
+++ 2.6.9-rc1/arch/um/kernel/irq_user.c	2004-09-10 13:11:06.000000000 -0400
@@ -364,6 +364,20 @@
 	irq_unlock(flags);
 }
 
+int deactivate_all_fds(void)
+{
+	struct irq_fd *irq;
+	int err;
+
+	for(irq=active_fds;irq != NULL;irq = irq->next){
+		err = os_clear_fd_async(irq->fd);
+		if(err)
+			return(err);
+	}
+
+	return(0);
+}
+
 void forward_ipi(int fd, int pid)
 {
 	int err;
Index: 2.6.9-rc1/arch/um/kernel/time.c
===================================================================
--- 2.6.9-rc1.orig/arch/um/kernel/time.c	2004-09-09 19:46:14.000000000 -0400
+++ 2.6.9-rc1/arch/um/kernel/time.c	2004-09-10 13:11:06.000000000 -0400
@@ -54,6 +54,15 @@
 		       errno);
 }
 
+void disable_timer(void)
+{
+	struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
+	if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
+	   (setitimer(ITIMER_REAL, &disable, NULL) < 0))
+		printk("disnable_timer - setitimer failed, errno = %d\n",
+		       errno);
+}
+
 void switch_timers(int to_real)
 {
 	struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
Index: 2.6.9-rc1/arch/um/os-Linux/file.c
===================================================================
--- 2.6.9-rc1.orig/arch/um/os-Linux/file.c	2004-09-09 19:46:14.000000000 -0400
+++ 2.6.9-rc1/arch/um/os-Linux/file.c	2004-09-10 13:11:06.000000000 -0400
@@ -495,6 +495,16 @@
 	return(0);
 }
 
+int os_clear_fd_async(int fd)
+{
+	int flags = fcntl(fd, F_GETFL);
+
+	flags &= ~(O_ASYNC | O_NONBLOCK);
+	if(fcntl(fd, F_SETFL, flags) < 0)
+		return(-errno);
+	return(0);
+}
+
 int os_set_fd_block(int fd, int blocking)
 {
 	int flags;


                 reply	other threads:[~2004-09-10 17:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200409101828.i8AISG0O003438@ccure.user-mode-linux.org \
    --to=jdike@addtoit.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®