Skip to content
  • Ben Pfaff's avatar
    squish-pty: Flush buffered data from pty to stdout when pty's slave closed · b913988a
    Ben Pfaff authored
    When the slave side of the pty is closed, the "read" system call returns
    EIO.  In this situation, squish-pty failed to flush any output that it
    already had in its buffer (up to 16 bytes) to stdout.  This could cause
    the "Powering off..." message printed by Pintos just before exiting to
    be missing from the output.
    
    This usually didn't happen, because there are two other exit paths from
    the relay() function that does most of squish-pty's work.  The most common
    exit path was (evidently) the one which detected that the child process
    had died, which did properly flush the buffer.  (The third path was wrong
    too, and this patch fixes that one too.)
    
    This patch fixes the problem by using a single exit path from relay() that
    always reads any remaining input from the pty (if it is open) and flushes
    it to stdout.
    
    Reported by Borja Sotomayor <borja@cs.uchicago.edu>.
    b913988a