Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/irix Added a sleep on the parent so that the pare...



details:   https://anonhg.NetBSD.org/src/rev/efb4c9e89495
branches:  trunk
changeset: 535233:efb4c9e89495
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Aug 12 20:11:38 2002 +0000

description:
Added a sleep on the parent so that the parent cannot die while the child
needs to access information from it.

diffstat:

 sys/compat/irix/irix_prctl.c |  29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diffs (85 lines):

diff -r f171aaf92960 -r efb4c9e89495 sys/compat/irix/irix_prctl.c
--- a/sys/compat/irix/irix_prctl.c      Mon Aug 12 20:03:05 2002 +0000
+++ b/sys/compat/irix/irix_prctl.c      Mon Aug 12 20:11:38 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_prctl.c,v 1.14 2002/08/02 23:02:51 manu Exp $ */
+/*     $NetBSD: irix_prctl.c,v 1.15 2002/08/12 20:11:38 manu Exp $ */
 
 /*-
  * Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.14 2002/08/02 23:02:51 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.15 2002/08/12 20:11:38 manu Exp $");
 
 #include <sys/errno.h>
 #include <sys/types.h>
@@ -75,6 +75,7 @@
        int isc_inh;
        struct proc *isc_parent;
        struct irix_share_group *isc_share_group;
+       int isc_child_done;
 }; 
 static void irix_sproc_child __P((struct irix_sproc_child_args *));
 static int irix_sproc __P((void *, unsigned int, void *, caddr_t, size_t, 
@@ -375,6 +376,7 @@
        isc->isc_inh = inh;
        isc->isc_parent = p;
        isc->isc_share_group = isg;
+       isc->isc_child_done = 0;
 
        if (inh & IRIX_PR_SADDR)
                ied->ied_shareaddr = 1;
@@ -383,6 +385,15 @@
            (void *)irix_sproc_child, (void *)isc, retval, &p2)) != 0)
                return error;
 
+       /*
+        * The child needs the parent to stay alive until it has
+        * copied a few things from it. We sleep whatever happen
+        * until the child is done.
+        */
+       while (!isc->isc_child_done)
+               (void)tsleep(&isc->isc_child_done, PZERO, "sproc", 0);
+       free(isc, M_TEMP);
+
        retval[0] = (register_t)p2->p_pid;
        retval[1] = 0;
 
@@ -425,7 +436,8 @@
                error = uvm_map_extract(&parent->p_vmspace->vm_map, 
                    vm_min, vm_len, &p2->p_vmspace->vm_map, &dstaddrp, 0);
                if (error != 0) {
-                       free(isc, M_TEMP);
+                       isc->isc_child_done = 1;
+                       wakeup(&isc->isc_child_done);
                        killproc(p2, "failed to initialize share group VM");
                }
 
@@ -436,7 +448,8 @@
                /* Remap the process private arena (unshared) */
                error = irix_prda_init(p2);
                if (error != 0) {
-                       free(isc, M_TEMP);
+                       isc->isc_child_done = 1;
+                       wakeup(&isc->isc_child_done);
                        killproc(p2, "failed to initialize share group VM");
                }
        }
@@ -500,7 +513,13 @@
        if (inh & IRIX_PR_SADDR) 
                ied->ied_shareaddr = 1;
 
-       free(isc, M_TEMP);
+       /*
+        * wakeup the parent as it can now die without 
+        * causing a panic in the child.
+        */
+       isc->isc_child_done = 1;
+       wakeup(&isc->isc_child_done);
+
        /*
         * Return to userland for a newly created process
         */



Home | Main Index | Thread Index | Old Index