mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries.Brouwer@cwi.nl
To: akpm@osdl.org, torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] select fix
Date: Tue, 29 Jul 2003 16:12:58 +0200 (MEST)	[thread overview]
Message-ID: <UTC200307291412.h6TECwA17034.aeb@smtp.cwi.nl> (raw)

Recently people complained on lk about a problem: one sees

select(2, NULL, [1], NULL, NULL)        = 1 (out [1])
write(1, "hi\n", 3)                     = -1 EAGAIN (Resource temporarily unavailable)

for a stopped tty opened with O_NONBLOCK. This violates POSIX,
and the 100% CPU use in a select loop does not look pretty either.
The below fixes this.

Andries

diff -u --recursive --new-file -X /linux/dontdiff a/drivers/char/n_tty.c b/drivers/char/n_tty.c
--- a/drivers/char/n_tty.c	Thu Jul  3 09:26:43 2003
+++ b/drivers/char/n_tty.c	Tue Jul 29 16:53:10 2003
@@ -1231,7 +1231,8 @@
 }
 
 /* Called without the kernel lock held - fine */
-static unsigned int normal_poll(struct tty_struct * tty, struct file * file, poll_table *wait)
+static unsigned int
+normal_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
 {
 	unsigned int mask = 0;
 
@@ -1251,27 +1252,27 @@
 		else
 			tty->minimum_to_wake = 1;
 	}
-	if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS)
+	if (!tty->stopped && tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS)
 		mask |= POLLOUT | POLLWRNORM;
 	return mask;
 }
 
 struct tty_ldisc tty_ldisc_N_TTY = {
-	TTY_LDISC_MAGIC,	/* magic */
-	"n_tty",		/* name */
-	0,			/* num */
-	0,			/* flags */
-	n_tty_open,		/* open */
-	n_tty_close,		/* close */
-	n_tty_flush_buffer,	/* flush_buffer */
-	n_tty_chars_in_buffer,	/* chars_in_buffer */
-	read_chan,		/* read */
-	write_chan,		/* write */
-	n_tty_ioctl,		/* ioctl */
-	n_tty_set_termios,	/* set_termios */
-	normal_poll,		/* poll */
-	n_tty_receive_buf,	/* receive_buf */
-	n_tty_receive_room,	/* receive_room */
-	n_tty_write_wakeup	/* write_wakeup */
+	.magic =		TTY_LDISC_MAGIC,
+	.name =			"n_tty",
+	.num =			0,
+	.flags =		0,
+	.open =			n_tty_open,
+	.close =		n_tty_close,
+	.flush_buffer =		n_tty_flush_buffer,
+	.chars_in_buffer =	n_tty_chars_in_buffer,
+	.read =			read_chan,
+	.write =		write_chan,
+	.ioctl =		n_tty_ioctl,
+	.set_termios =		n_tty_set_termios,
+	.poll =			normal_poll,
+	.receive_buf =		n_tty_receive_buf,
+	.receive_room =		n_tty_receive_room,
+	.write_wakeup =		n_tty_write_wakeup
 };
 

             reply	other threads:[~2003-07-29 14:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-29 14:12 Andries.Brouwer [this message]
2003-07-29 17:36 ` Andrew Morton
2003-07-29 17:48   ` Valdis.Kletnieks
2003-07-29 18:09     ` Manfred Spraul
2003-07-29 17:57   ` Manfred Spraul
2003-07-29 19:58 Andries.Brouwer
2003-07-29 20:18 Andries.Brouwer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=UTC200307291412.h6TECwA17034.aeb@smtp.cwi.nl \
    --to=andries.brouwer@cwi.nl \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®