Skip to contentSkip to conversation

Enabling the echo of ctrl-C (and the like)

PATCH In review Joe Peterson 2 participants 2 messages Dec 6, 2007 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Enabling the echo of ctrl-C (and the like)

Attached is a patch that turns on INTR/QUIT/SUSP echoing in the N_TTY line discipline (e.g. ctrl-C will appear as "^C" if stty echoctl is set and ctrl-C is set as INTR).

Linux seems to be the only unix-like OS (recently I've verified this on Solaris, BSD, and Mac OS X) that does *not* behave this way, and I really miss this as a good visual confirmation of the interrupt of a program in the console or xterm. I remember this fondly from many Unixs I've used over the years as well. Bringing this to Linux also seems like a good way to make it yet more compliant with standard unix-like behavior.

The fix is pretty trivial. Let me know if you think this is a candidate for inclusion in the kernel.

Thanks, Joe

drivers/char/n_tty.c +16 -1
@@ -760,7 +760,22 @@
 		signal = SIGTSTP;
 		if (c == SUSP_CHAR(tty)) {
 send_signal:
-			isig(signal, tty, 0);
+			/*
+			 * Echo character, and then send the signal.
+			 * Note that we do not use isig() here because we want
+			 * the order to be:
+			 * 1) flush, 2) echo, 3) signal
+			 */
+			if (!L_NOFLSH(tty)) {
+				n_tty_flush_buffer(tty);
+				if (tty->driver->flush_buffer)
+					tty->driver->flush_buffer(tty);
+			}
+			if (L_ECHO(tty)) {
+				echo_char(c, tty);
+			}
+			if (tty->pgrp)
+				kill_pgrp(tty->pgrp, signal, 1);
 			return;
 		}
 	}
#1 lore raw
Quoted 6 lines · Joe Peterson

I've used over the years as well. Bringing this to Linux also seems like a good way to make it yet more compliant with standard unix-like behavior.

The fix is pretty trivial. Let me know if you think this is a candidate for inclusion in the kernel.

If it matches other platforms and doesn't seem to break anything then I don't see a problem.