summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/os/exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/os/exit.c')
-rw-r--r--usr/src/uts/common/os/exit.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/usr/src/uts/common/os/exit.c b/usr/src/uts/common/os/exit.c
index 83a6978064..7fcba5d9ec 100644
--- a/usr/src/uts/common/os/exit.c
+++ b/usr/src/uts/common/os/exit.c
@@ -21,7 +21,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -75,10 +75,6 @@
#include <sys/sdt.h>
#include <sys/corectl.h>
-#if defined(__x86)
-extern void ldt_free(proc_t *pp);
-#endif
-
/*
* convert code/data pair into old style wait status
*/
@@ -538,14 +534,6 @@ proc_exit(int why, int what)
} else
mutex_exit(&pidlock);
-#if defined(__x86)
- /*
- * If the process was using a private LDT then free it.
- */
- if (p->p_ldt)
- ldt_free(p);
-#endif
-
#if defined(__sparc)
if (p->p_utraps != NULL)
utrap_free(p);
@@ -769,6 +757,24 @@ proc_exit(int why, int what)
p->p_tidhash_sz = 0;
/*
+ * If the process has context ops installed, call the exit routine
+ * on behalf of this last remaining thread. Normally exitpctx() is
+ * called during thread_exit() or lwp_exit(), but because this is the
+ * last thread in the process, we must call it here. By the time
+ * thread_exit() is called (below), the association with the relevant
+ * process has been lost.
+ *
+ * We also free the context here.
+ */
+ if (p->p_pctx) {
+ kpreempt_disable();
+ exitpctx(p);
+ kpreempt_enable();
+
+ freepctx(p, 0);
+ }
+
+ /*
* curthread's proc pointer is changed to point at p0 because
* curthread's original proc pointer can be freed as soon as
* the child sends a SIGCLD to its parent.