- /*
- * It would be nicer if we could integrate this redirection more with
- * the routines in sh.sem.c by doing a fake execute on a builtin
- * function that was piped out.
- */
- mypipe(pvec);
- if (pfork(&faket, -1) == 0) {
- struct wordent paraml;
- struct command *t;
-
- (void) close(pvec[0]);
- (void) dmove(pvec[1], 1);
- (void) dmove(SHDIAG, 2);
- initdesc();
- arginp = cp;
- while (*cp)
- *cp++ &= TRIM;
- (void) lex(¶ml);
- if (err)
- error(err);
- alias(¶ml);
- t = syntax(paraml.next, ¶ml, 0);
- if (err)
- error(err);
- if (t)
- t->t_dflg |= FPAR;
- (void) signal(SIGTSTP, SIG_IGN);
- (void) signal(SIGTTIN, SIG_IGN);
- (void) signal(SIGTTOU, SIG_IGN);
- execute(t, -1);
- exitstat();
- }
- xfree(cp);
- (void) close(pvec[1]);
- do {
- int cnt = 0;
- for (;;) {
- if (icnt == 0) {
- ip = ibuf;
- icnt = read(pvec[0], ip, BUFSIZ);
- if (icnt <= 0) {
- c = -1;
- break;
- }
- }
- if (hadnl)
- break;
- --icnt;
- c = (*ip++ & TRIM);
- if (c == 0)
- break;
- if (c == '\n') {
- /*
- * Continue around the loop one more time, so
- * that we can eat the last newline without
- * terminating this word.
- */
- hadnl = 1;
- continue;
- }
- if (!quoted && (c == ' ' || c == '\t'))
- break;
- cnt++;
- psave(c | quoted);
+ for (;;) {
+ if (icnt == 0) {
+ int i;
+
+ ip = ibuf;
+ do
+ icnt = read(pvec[0], tibuf, BUFSIZ);
+ while (icnt == -1 && errno == EINTR);
+ if (icnt <= 0) {
+ c = -1;
+ break;