Commit 791c4b04 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix select() with an xoffed tty

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.
parent a74ccc26
...@@ -1251,7 +1251,8 @@ static unsigned int normal_poll(struct tty_struct * tty, struct file * file, pol ...@@ -1251,7 +1251,8 @@ static unsigned int normal_poll(struct tty_struct * tty, struct file * file, pol
else else
tty->minimum_to_wake = 1; tty->minimum_to_wake = 1;
} }
if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS) if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS &&
tty->driver->write_room(tty) > 0)
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
return mask; return mask;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment