public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Peterson <joe@skyrush.com>
To: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	alan@lxorguk.ukuu.org.uk
Subject: [PATCH] Resume TTY on SUSP and fix CRNL order in N_TTY line discipline
Date: Sun, 24 Feb 2008 23:28:59 -0700	[thread overview]
Message-ID: <47C2602B.7010108@skyrush.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

Here is a small patch to further refine behavior in n_tty.c.  It
addresses two fine points in how received characters are treated - one
to handle the signal chars in stopped TTYs more consistently, and the
other to make the order of cr/nl translations more logical and
consistent with other Unixes when unusual stty settings are used (e.g.
if someone were to set intr to ^J).

						-Joe

[-- Attachment #2: resume-tty-on-susp-and-fix-crnl-order-in-n_tty-line-discipline.patch --]
[-- Type: text/plain, Size: 1853 bytes --]

Refine these behaviors in the N_TTY line discipline:

1) Handle the signal characters consistently when received in
   a stopped TTY so that SUSP (typically ctrl-Z) behaves like
   INTR and QUIT in resuming a stopped TTY.

2) Adjust the order in which the IGNCR/ICRNL/INLCR processing
   is applied to be more logical and consistent with the behavior
   of other Unix systems.

Signed-off-by: Joe Peterson <joe@skyrush.com>
---

diff -puN drivers/char/n_tty.c~resume-tty-on-susp-and-fix-crnl-order-in-n_tty-line-discipline drivers/char/n_tty.c
--- a/drivers/char/n_tty.c~resume-tty-on-susp-and-fix-crnl-order-in-n_tty-line-discipline	2008-02-24 08:36:24.000000000 -0700
+++ a/drivers/char/n_tty.c	2008-02-24 21:08:15.000000000 -0700
@@ -701,7 +701,7 @@ static inline void n_tty_receive_char(st
 
 	if (tty->stopped && !tty->flow_stopped && I_IXON(tty) &&
 	    ((I_IXANY(tty) && c != START_CHAR(tty) && c != STOP_CHAR(tty)) ||
-	     c == INTR_CHAR(tty) || c == QUIT_CHAR(tty)))
+	     c == INTR_CHAR(tty) || c == QUIT_CHAR(tty) || c == SUSP_CHAR(tty)))
 		start_tty(tty);
 
 	if (tty->closing) {
@@ -739,13 +739,6 @@ static inline void n_tty_receive_char(st
 		return;
 	}
 
-	if (c == '\r') {
-		if (I_IGNCR(tty))
-			return;
-		if (I_ICRNL(tty))
-			c = '\n';
-	} else if (c == '\n' && I_INLCR(tty))
-		c = '\r';
 	if (I_IXON(tty)) {
 		if (c == START_CHAR(tty)) {
 			start_tty(tty);
@@ -756,6 +749,7 @@ static inline void n_tty_receive_char(st
 			return;
 		}
 	}
+
 	if (L_ISIG(tty)) {
 		int signal;
 		signal = SIGINT;
@@ -785,6 +779,15 @@ send_signal:
 			return;
 		}
 	}
+
+	if (c == '\r') {
+		if (I_IGNCR(tty))
+			return;
+		if (I_ICRNL(tty))
+			c = '\n';
+	} else if (c == '\n' && I_INLCR(tty))
+		c = '\r';
+
 	if (tty->icanon) {
 		if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) ||
 		    (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) {

                 reply	other threads:[~2008-02-25  6:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=47C2602B.7010108@skyrush.com \
    --to=joe@skyrush.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.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