Source-Changes-HG archive

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

[src/trunk]: src/bin/sh Back out previous vfork changes.



details:   https://anonhg.NetBSD.org/src/rev/702f53327a9c
branches:  trunk
changeset: 486434:702f53327a9c
user:      elric <elric%NetBSD.org@localhost>
date:      Mon May 22 10:18:46 2000 +0000

description:
Back out previous vfork changes.

diffstat:

 bin/sh/eval.c  |   97 ++++--------------------------
 bin/sh/exec.c  |   25 ++-----
 bin/sh/exec.h  |    4 +-
 bin/sh/input.c |   18 +----
 bin/sh/input.h |    4 +-
 bin/sh/jobs.c  |  178 ++++++++++++++++++++++++--------------------------------
 bin/sh/jobs.h  |    4 +-
 bin/sh/main.c  |    6 +-
 bin/sh/redir.c |   16 +---
 bin/sh/redir.h |    5 +-
 bin/sh/shell.h |   11 +---
 bin/sh/trap.c  |   57 +++++++----------
 bin/sh/trap.h  |    8 +-
 bin/sh/var.c   |   14 ++--
 bin/sh/var.h   |    4 +-
 15 files changed, 150 insertions(+), 301 deletions(-)

diffs (truncated from 990 to 300 lines):

diff -r 265bf4ce24fb -r 702f53327a9c bin/sh/eval.c
--- a/bin/sh/eval.c     Mon May 22 09:02:07 2000 +0000
+++ b/bin/sh/eval.c     Mon May 22 10:18:46 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eval.c,v 1.55 2000/05/17 07:37:12 elric Exp $  */
+/*     $NetBSD: eval.c,v 1.56 2000/05/22 10:18:46 elric Exp $  */
 
 /*-
  * Copyright (c) 1993
@@ -41,24 +41,17 @@
 #if 0
 static char sccsid[] = "@(#)eval.c     8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.55 2000/05/17 07:37:12 elric Exp $");
+__RCSID("$NetBSD: eval.c,v 1.56 2000/05/22 10:18:46 elric Exp $");
 #endif
 #endif /* not lint */
 
-#include <errno.h>
-#include <fcntl.h>
-#include <paths.h>
 #include <signal.h>
 #include <unistd.h>
 
-#include <sys/types.h>
-#include <sys/wait.h>
-
 /*
  * Evaluate a command.
  */
 
-#include "main.h"
 #include "shell.h"
 #include "nodes.h"
 #include "syntax.h"
@@ -595,7 +588,6 @@
 }
 
 
-int vforked = 0;
 
 /*
  * Execute a simple command.
@@ -635,7 +627,6 @@
        (void) &flags;
 #endif
 
-       vforked = 0;
        /* First expand the arguments. */
        TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
        setstackmark(&smark);
@@ -745,72 +736,10 @@
                        if (pipe(pip) < 0)
                                error("Pipe call failed");
                }
-#ifdef DO_SHAREDVFORK
-               /* It is essential that if DO_SHAREDVFORK is defined that the
-                * child's address space is actually shared with the parent as
-                * we rely on this.
-                */
-               if (cmdentry.cmdtype == CMDNORMAL) {
-                       pid_t   pid;
-
-                       INTOFF;
-                       savelocalvars = localvars;
-                       localvars = NULL;
-                       for (sp = varlist.list ; sp ; sp = sp->next)
-                               mklocal(sp->text, VEXPORT);
-                       vforked = 1;
-                       switch (pid = vfork()) {
-                       case -1:
-                               TRACE(("Vfork failed, errno=%d", errno));
-                               INTON;
-                               error("Cannot vfork");
-                               break;
-                       case 0:
-                               /* Make sure that exceptions only unwind to
-                                * after the vfork(2)
-                                */
-                               if (setjmp(jmploc.loc)) {
-                                       if (exception == EXSHELLPROC) {
-                                               /* We can't progress with the vfork,
-                                                * so, set vforked = 2 so the parent
-                                                * knows, and _exit();
-                                                */
-                                               vforked = 2;
-                                               _exit(0);
-                                       } else {
-                                               _exit(exerrno);
-                                       }
-                               }
-                               savehandler = handler;
-                               handler = &jmploc;
-                               forkchild(jp, cmd, mode, vforked);
-                               break;
-                       default:
-                               handler = savehandler;  /* restore from vfork(2) */
-                               poplocalvars();
-                               localvars = savelocalvars;
-                               if (vforked == 2) {
-                                       vforked = 0;
-                                       waitpid(pid, NULL, 0);
-                                       /* We need to progress in a normal fork fashion */
-                                       goto normal_fork;
-                               }
-                               vforked = 0;
-                               forkparent(jp, cmd, mode, pid);
-                               goto parent;
-                       }
-               } else {
-normal_fork:
-#endif
-                       if (forkshell(jp, cmd, mode) != 0)
-                               goto parent;    /* at end of routine */
-#ifdef DO_SHAREDVFORK
-               }
-#endif
+               if (forkshell(jp, cmd, mode) != 0)
+                       goto parent;    /* at end of routine */
                if (flags & EV_BACKCMD) {
-                       if (!vforked) {
-                               FORCEINTON;
-                       }
+                       FORCEINTON;
                        close(pip[0]);
                        if (pip[1] != 1) {
                                close(1);
@@ -854,7 +783,7 @@
                savehandler = handler;
                handler = &jmploc;
                for (sp = varlist.list ; sp ; sp = sp->next)
-                       mklocal(sp->text, 0);
+                       mklocal(sp->text);
                funcnest++;
                evaltree(cmdentry.u.func, flags & EV_TESTED);
                funcnest--;
@@ -933,13 +862,12 @@
 #ifdef DEBUG
                trputs("normal command:  ");  trargs(argv);
 #endif
-               clearredir(vforked?REDIR_VFORK:0);
-               redirect(cmd->ncmd.redirect, vforked?REDIR_VFORK:0);
-               if (!vforked)
-                       for (sp = varlist.list ; sp ; sp = sp->next)
-                               setvareq(sp->text, VEXPORT|VSTACK);
+               clearredir();
+               redirect(cmd->ncmd.redirect, 0);
+               for (sp = varlist.list ; sp ; sp = sp->next)
+                       setvareq(sp->text, VEXPORT|VSTACK);
                envp = environment();
-               shellexec(argv, envp, pathval(), cmdentry.u.index, vforked);
+               shellexec(argv, envp, pathval(), cmdentry.u.index);
        }
        goto out;
 
@@ -964,6 +892,7 @@
 }
 
 
+
 /*
  * Search for a command.  This is called before we fork so that the
  * location of the command will be available in the parent as well as
@@ -1093,7 +1022,7 @@
                optschanged();
                for (sp = cmdenviron; sp ; sp = sp->next)
                        setvareq(sp->text, VEXPORT|VSTACK);
-               shellexec(argv + 1, environment(), pathval(), 0, 0);
+               shellexec(argv + 1, environment(), pathval(), 0);
        }
        return 0;
 }
diff -r 265bf4ce24fb -r 702f53327a9c bin/sh/exec.c
--- a/bin/sh/exec.c     Mon May 22 09:02:07 2000 +0000
+++ b/bin/sh/exec.c     Mon May 22 10:18:46 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec.c,v 1.28 2000/05/13 20:50:14 elric Exp $  */
+/*     $NetBSD: exec.c,v 1.29 2000/05/22 10:18:46 elric Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,17 +41,15 @@
 #if 0
 static char sccsid[] = "@(#)exec.c     8.4 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: exec.c,v 1.28 2000/05/13 20:50:14 elric Exp $");
+__RCSID("$NetBSD: exec.c,v 1.29 2000/05/22 10:18:46 elric Exp $");
 #endif
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/wait.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <stdio.h>
 #include <stdlib.h>
 
 /*
@@ -104,7 +102,7 @@
 int exerrno = 0;                       /* Last exec error */
 
 
-STATIC void tryexec __P((char *, char **, char **, int));
+STATIC void tryexec __P((char *, char **, char **));
 STATIC void execinterp __P((char **, char **));
 STATIC void printentry __P((struct tblentry *, int));
 STATIC void clearcmdentry __P((int));
@@ -119,23 +117,22 @@
  */
 
 void
-shellexec(argv, envp, path, idx, vforked)
+shellexec(argv, envp, path, idx)
        char **argv, **envp;
        const char *path;
        int idx;
-       int vforked;
 {
        char *cmdname;
        int e;
 
        if (strchr(argv[0], '/') != NULL) {
-               tryexec(argv[0], argv, envp, vforked);
+               tryexec(argv[0], argv, envp);
                e = errno;
        } else {
                e = ENOENT;
                while ((cmdname = padvance(&path, argv[0])) != NULL) {
                        if (--idx < 0 && pathopt == NULL) {
-                               tryexec(cmdname, argv, envp, vforked);
+                               tryexec(cmdname, argv, envp);
                                if (errno != ENOENT && errno != ENOTDIR)
                                        e = errno;
                        }
@@ -161,11 +158,10 @@
 
 
 STATIC void
-tryexec(cmd, argv, envp, vforked)
+tryexec(cmd, argv, envp)
        char *cmd;
        char **argv;
        char **envp;
-       int vforked;
        {
        int e;
 #ifndef BSD
@@ -181,13 +177,6 @@
 #endif
        e = errno;
        if (e == ENOEXEC) {
-               if (vforked) {
-                       /* We are currently vfork(2)ed, so raise an
-                        * exception, and evalcommand will try again
-                        * with a normal fork(2).
-                        */
-                       exraise(EXSHELLPROC);
-               }
                initshellproc();
                setinputfile(cmd, 0);
                commandname = arg0 = savestr(argv[0]);
diff -r 265bf4ce24fb -r 702f53327a9c bin/sh/exec.h
--- a/bin/sh/exec.h     Mon May 22 09:02:07 2000 +0000
+++ b/bin/sh/exec.h     Mon May 22 10:18:46 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec.h,v 1.16 2000/05/13 20:50:14 elric Exp $  */
+/*     $NetBSD: exec.h,v 1.17 2000/05/22 10:18:47 elric Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -60,7 +60,7 @@
 extern const char *pathopt;    /* set by padvance */
 extern int exerrno;            /* last exec error */
 
-void shellexec __P((char **, char **, const char *, int, int))
+void shellexec __P((char **, char **, const char *, int))
     __attribute__((noreturn));
 char *padvance __P((const char **, const char *));
 int hashcmd __P((int, char **));
diff -r 265bf4ce24fb -r 702f53327a9c bin/sh/input.c
--- a/bin/sh/input.c    Mon May 22 09:02:07 2000 +0000
+++ b/bin/sh/input.c    Mon May 22 10:18:46 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: input.c,v 1.33 2000/05/13 20:50:14 elric Exp $ */
+/*     $NetBSD: input.c,v 1.34 2000/05/22 10:18:47 elric Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)input.c    8.3 (Berkeley) 6/9/95";
 #else
-__RCSID("$NetBSD: input.c,v 1.33 2000/05/13 20:50:14 elric Exp $");
+__RCSID("$NetBSD: input.c,v 1.34 2000/05/22 10:18:47 elric Exp $");
 #endif
 #endif /* not lint */
 
@@ -506,22 +506,10 @@



Home | Main Index | Thread Index | Old Index