Module Name:    src
Committed By:   reinoud
Date:           Sat Aug 27 21:19:18 UTC 2011

Modified Files:
        src/sys/arch/usermode/usermode: trap.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/usermode/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/usermode/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.7 src/sys/arch/usermode/usermode/trap.c:1.8
--- src/sys/arch/usermode/usermode/trap.c:1.7	Sat Aug 27 18:01:37 2011
+++ src/sys/arch/usermode/usermode/trap.c	Sat Aug 27 21:19:17 2011
@@ -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 <rein...@netbsd.org>
@@ -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;

Reply via email to