Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode/usermode Catch the atexit() so we can bypa...



details:   https://anonhg.NetBSD.org/src/rev/df034dab45a8
branches:  trunk
changeset: 768841:df034dab45a8
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Sat Aug 27 21:19:17 2011 +0000

description:
Catch the atexit() so we can bypass the libc feature that if one ucontext()
ends that it then call exit()

diffstat:

 sys/arch/usermode/usermode/trap.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (58 lines):

diff -r f48a00782640 -r df034dab45a8 sys/arch/usermode/usermode/trap.c
--- a/sys/arch/usermode/usermode/trap.c Sat Aug 27 21:17:26 2011 +0000
+++ b/sys/arch/usermode/usermode/trap.c Sat Aug 27 21:19:17 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.7 2011/08/27 18:01:37 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.8 2011/08/27 21:19:17 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -27,12 +27,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.7 2011/08/27 18:01:37 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.8 2011/08/27 21:19:17 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
+#include <sys/systm.h>
+#include <sys/userret.h>
 #include <uvm/uvm_extern.h>
 #include <machine/cpu.h>
 //#include <machine/ctlreg.h>
@@ -46,6 +48,8 @@
 
 void setup_signal_handlers(void);
 static void mem_access_handler(int sig, siginfo_t *info, void *ctx);
+static void exit_func(void);
+
 
 static struct sigaction sa;
 extern int errno;
@@ -53,7 +57,14 @@
 void
 startlwp(void *arg)
 {
+}
 
+static void
+exit_func(void)
+{
+       if (panicstr == NULL)
+               child_return(curlwp);
+       panic("atexit() with panic `%s`", panicstr);
 }
 
 void
@@ -66,6 +77,8 @@
                panic("couldn't register SIGSEGV handler : %d", errno);
        if (thunk_sigaction(SIGBUS, &sa, NULL) == -1)
                panic("couldn't register SIGBUS handler : %d", errno);
+       if (thunk_atexit(exit_func))
+               panic("couldn't register atexit() handler : %d", errno);
 }
 
 static struct trapframe kernel_tf;



Home | Main Index | Thread Index | Old Index