+ }
+
+ /*
+ * There is a critical section here while we are pushing down the input
+ * stream since we have stuff in different structures. If we weren't
+ * careful an interrupt could corrupt SHIN's Bin structure and kill the
+ * shell.
+ *
+ * We could avoid the critical region by grouping all the stuff in a single
+ * structure and pointing at it to move it all at once. This is less
+ * efficient globally on many variable references however.
+ */
+ insource = 1;
+ getexit(oldexit);
+ omask = 0;
+
+ if (setintr)
+ omask = sigblock(sigmask(SIGINT));
+ /* Setup the new values of the state stuff saved above */
+ bcopy((char *) &B, (char *) &(saveB), sizeof(B));
+ fbuf = NULL;
+ fseekp = feobp = fblocks = 0;
+ oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
+ intty = isatty(SHIN), whyles = 0, gointr = 0;
+ evalvec = 0;
+ evalp = 0;
+ enterhist = hflg;
+ if (enterhist)
+ HIST = '\0';
+
+ /*
+ * Now if we are allowing commands to be interrupted, we let ourselves be
+ * interrupted.
+ */
+ if (setintr)
+ (void) sigsetmask(omask);
+ settell();
+
+ if ((my_reenter = setexit()) == 0)
+ process(0); /* 0 -> blow away on errors */
+
+ if (setintr)
+ (void) sigsetmask(omask);
+ if (oSHIN >= 0) {
+ register int i;
+
+ /* We made it to the new state... free up its storage */
+ /* This code could get run twice but xfree doesn't care */
+ for (i = 0; i < fblocks; i++)
+ xfree((ptr_t) fbuf[i]);
+ xfree((ptr_t) fbuf);
+
+ /* Reset input arena */
+ bcopy((char *) &(saveB), (char *) &B, sizeof(B));
+
+ (void) close(SHIN), SHIN = oSHIN;
+ arginp = oarginp, onelflg = oonelflg;
+ evalp = oevalp, evalvec = oevalvec;
+ intty = oldintty, whyles = oldwhyl, gointr = ogointr;
+ if (enterhist)
+ HIST = OHIST;
+ enterhist = oenterhist;
+ cantell = otell;
+ }
+
+ resexit(oldexit);
+ /*
+ * If process reset() (effectively an unwind) then we must also unwind.
+ */
+ if (my_reenter)
+ stderror(ERR_SILENT);
+ insource = oinsource;