• Andrew Morton's avatar
    [PATCH] fix select() with an xoffed tty · 791c4b04
    Andrew Morton authored
    From: Manfred Spraul <manfred@colorfullife.com>
    
    Eli Barzilay noticed that select() for tty devices is broken: For
    stopped tty devices, select says POLLOUT and write fails with -EAGAIN.
    
        http://marc.theaimsgroup.com/?l=linux-kernel&m=105902461110282&w=2
    
    I've tracked this back to normal_poll in drivers/char/n_tty.c:
    
     > if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS)
     >                mask |= POLLOUT | POLLWRNORM;
    
    It assumes that a following write will succeed if less than 256 bytes
    are in the write buffer right now. This assumption is wrong for
    con_write_room: if the console is stopped, it returns 0 bytes buffer
    size (con_write_room()). Ditto for pty_write_room.
    791c4b04
n_tty.c 30.1 KB