Source-Changes-HG archive

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

[src/trunk]: src/sys A few things to make the Linux clone(2) emulation work a...



details:   https://anonhg.NetBSD.org/src/rev/240bb5f331c8
branches:  trunk
changeset: 474688:240bb5f331c8
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 15 23:18:41 1999 +0000

description:
A few things to make the Linux clone(2) emulation work a bit better:
- When the exit signal is specified to be 0, don't just assume they
  meant SIGCHLD.  In the Linux world, this appears to mean "don't deliver
  an exit signal at all".
- Simplify P_EXITSIG(); don't check against initproc here, just change
  the exit signal to SIGCHLD if reparenting to initproc.

A very simple clone(2) test program now works, and the MpegTV package
starts, but doesn't run properly yet (I believe there is a separate
bug which keeps it from working properly).

diffstat:

 sys/compat/linux/common/linux_misc.c |   6 +-----
 sys/kern/kern_exit.c                 |  14 +++++++++-----
 sys/sys/proc.h                       |   9 ++++-----
 3 files changed, 14 insertions(+), 15 deletions(-)

diffs (93 lines):

diff -r 32291091f29a -r 240bb5f331c8 sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Thu Jul 15 22:00:40 1999 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Thu Jul 15 23:18:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_misc.c,v 1.58 1999/05/17 19:26:33 thorpej Exp $  */
+/*     $NetBSD: linux_misc.c,v 1.59 1999/07/15 23:18:41 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -955,10 +955,6 @@
                return (EINVAL);
        sig = linux_to_native_sig[sig];
 
-       /* XXX Is this the right thing? */
-       if (sig == 0)
-               sig = SIGCHLD;
-
        /*
         * Note that Linux does not provide a portable way of specifying
         * the stack area; the caller must know if the stack grows up
diff -r 32291091f29a -r 240bb5f331c8 sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Thu Jul 15 22:00:40 1999 +0000
+++ b/sys/kern/kern_exit.c      Thu Jul 15 23:18:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.69 1999/05/13 17:28:30 thorpej Exp $   */
+/*     $NetBSD: kern_exit.c,v 1.70 1999/07/15 23:18:43 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -377,7 +377,7 @@
                LIST_INSERT_HEAD(&zombproc, p, p_list);
 
                /* Wake up the parent so it can get exit status. */
-               if ((p->p_flag & P_FSTRACE) == 0)
+               if ((p->p_flag & P_FSTRACE) == 0 && p->p_exitsig != 0)
                        psignal(p->p_pptr, P_EXITSIG(p));
                wakeup((caddr_t)p->p_pptr);
        }
@@ -416,8 +416,8 @@
                 * if WALTSIG is set; wait for processes with p_exitsig ==
                 * SIGCHLD only if WALTSIG is clear.
                 */
-               if ((SCARG(uap, options) & WALTSIG) ? P_EXITSIG(p) == SIGCHLD :
-                                                     P_EXITSIG(p) != SIGCHLD)
+               if ((SCARG(uap, options) & WALTSIG) ?
+                   (p->p_exitsig == SIGCHLD) : (P_EXITSIG(p) != SIGCHLD))
                        continue;
 
                nfound++;
@@ -451,7 +451,8 @@
                                proc_reparent(p, t ? t : initproc);
                                p->p_oppid = 0;
                                p->p_flag &= ~(P_TRACED|P_WAITED|P_FSTRACE);
-                               psignal(p->p_pptr, P_EXITSIG(p));
+                               if (p->p_exitsig != 0)
+                                       psignal(p->p_pptr, P_EXITSIG(p));
                                wakeup((caddr_t)p->p_pptr);
                                return (0);
                        }
@@ -537,6 +538,9 @@
        if (child->p_pptr == parent)
                return;
 
+       if (parent == initproc)
+               child->p_exitsig = SIGCHLD;
+
        LIST_REMOVE(child, p_sibling);
        LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
        child->p_pptr = parent;
diff -r 32291091f29a -r 240bb5f331c8 sys/sys/proc.h
--- a/sys/sys/proc.h    Thu Jul 15 22:00:40 1999 +0000
+++ b/sys/sys/proc.h    Thu Jul 15 23:18:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: proc.h,v 1.77 1999/05/13 21:58:37 thorpej Exp $        */
+/*     $NetBSD: proc.h,v 1.78 1999/07/15 23:18:42 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1986, 1989, 1991, 1993
@@ -232,11 +232,10 @@
 #define        P_NOCLDWAIT     0x20000 /* No zombies if child dies */
 
 /*
- * Macro to compute the exit signal.
+ * Macro to compute the exit signal to be delivered.
  */
-#define        P_EXITSIG(p)    ((((p)->p_flag & (P_TRACED|P_FSTRACE)) ||       \
-                         (p)->p_pptr == initproc) ?                    \
-                        SIGCHLD : p->p_exitsig)
+#define        P_EXITSIG(p)    (((p)->p_flag & (P_TRACED|P_FSTRACE)) ? SIGCHLD : \
+                        p->p_exitsig)
 
 /*
  * MOVE TO ucred.h?



Home | Main Index | Thread Index | Old Index