654 * data back out to its stdout. The output pipe can
655 * fill up since we are stuck here in this loop and not
656 * draining the other pipe. We can try to read some of
657 * the data to see if we can drain the pipe so that the
658 * application can continue to make progress. The read
659 * is non-blocking so we won't hang here. We also wait
660 * a bit before retrying since there could be other
661 * reasons why the pipe is full and we don't want to
662 * continuously retry.
663 */
664 if (errno == EAGAIN) {
665 struct timespec rqtp;
666 int ln;
667 char obuf[ZLOGIN_BUFSIZ];
668
669 if ((ln = read(infd, obuf, ZLOGIN_BUFSIZ)) > 0)
670 (void) write(STDOUT_FILENO, obuf, ln);
671
672 /* sleep for 10 milliseconds */
673 rqtp.tv_sec = 0;
674 rqtp.tv_nsec = 10 * (NANOSEC / MILLISEC);
675 (void) nanosleep(&rqtp, NULL);
676 if (!dead)
677 goto retry;
678 }
679
680 return (-1);
681 }
682 beginning_of_line = (c == '\r' || c == '\n' ||
683 c == effective_termios.c_cc[VKILL] ||
684 c == effective_termios.c_cc[VEOL] ||
685 c == effective_termios.c_cc[VSUSP] ||
686 c == effective_termios.c_cc[VINTR]);
687 }
688 return (0);
689 }
690
691 /*
692 * This function prevents deadlock between zlogin and the application in the
693 * zone that it is talking to. This can happen when we read from zlogin's
694 * stdin and write the data down the pipe to the application. If the pipe
|
654 * data back out to its stdout. The output pipe can
655 * fill up since we are stuck here in this loop and not
656 * draining the other pipe. We can try to read some of
657 * the data to see if we can drain the pipe so that the
658 * application can continue to make progress. The read
659 * is non-blocking so we won't hang here. We also wait
660 * a bit before retrying since there could be other
661 * reasons why the pipe is full and we don't want to
662 * continuously retry.
663 */
664 if (errno == EAGAIN) {
665 struct timespec rqtp;
666 int ln;
667 char obuf[ZLOGIN_BUFSIZ];
668
669 if ((ln = read(infd, obuf, ZLOGIN_BUFSIZ)) > 0)
670 (void) write(STDOUT_FILENO, obuf, ln);
671
672 /* sleep for 10 milliseconds */
673 rqtp.tv_sec = 0;
674 rqtp.tv_nsec = MSEC2NSEC(10);
675 (void) nanosleep(&rqtp, NULL);
676 if (!dead)
677 goto retry;
678 }
679
680 return (-1);
681 }
682 beginning_of_line = (c == '\r' || c == '\n' ||
683 c == effective_termios.c_cc[VKILL] ||
684 c == effective_termios.c_cc[VEOL] ||
685 c == effective_termios.c_cc[VSUSP] ||
686 c == effective_termios.c_cc[VINTR]);
687 }
688 return (0);
689 }
690
691 /*
692 * This function prevents deadlock between zlogin and the application in the
693 * zone that it is talking to. This can happen when we read from zlogin's
694 * stdin and write the data down the pipe to the application. If the pipe
|