BSD 3 development
[unix-history] / usr / src / cmd / adb / format.c
index 6b4f9fc..5b85b2a 100644 (file)
@@ -255,13 +255,28 @@ shell()
 #ifndef EDDT
        INT             rc, status, unixpid;
        STRING          argp = lp;
 #ifndef EDDT
        INT             rc, status, unixpid;
        STRING          argp = lp;
+       STRING          getenv(), shell = getenv("SHELL");
+#ifdef VFORK
+       char            oldstlp;
+#endif
 
 
+       if (shell == 0)
+               shell = "/bin/sh";
        WHILE lastc!=EOR DO rdc(); OD
        WHILE lastc!=EOR DO rdc(); OD
+#ifndef VFORK
        IF (unixpid=fork())==0
        IF (unixpid=fork())==0
+#else
+       oldstlp = *lp;
+       IF (unixpid=vfork())==0
+#endif
        THEN    signal(SIGINT,sigint); signal(SIGQUIT,sigqit);
        THEN    signal(SIGINT,sigint); signal(SIGQUIT,sigqit);
-               *lp=0; execl("/bin/sh", "sh", "-c", argp, 0);
-               exit(16);
+               *lp=0; execl(shell, "sh", "-c", argp, 0);
+               _exit(16);
+#ifndef VFORK
        ELIF unixpid == -1
        ELIF unixpid == -1
+#else
+       ELIF *lp = oldstlp, unixpid == -1
+#endif
        THEN    error(NOFORK);
        ELSE    signal(SIGINT,1);
                WHILE (rc = wait(&status)) != unixpid ANDF rc != -1 DONE
        THEN    error(NOFORK);
        ELSE    signal(SIGINT,1);
                WHILE (rc = wait(&status)) != unixpid ANDF rc != -1 DONE