Potential bug with IXON handling in WSL #8578

Closed
opened 2026-01-31 01:33:01 +00:00 by claunia · 1 comment
Owner

Originally created by @srinathh on GitHub (May 25, 2020).

Environment

WSL Ubuntu 20.04

Steps to reproduce

  1. Enter Raw Mode
  2. Turn off IEXTEN behavior by using the IXON flag
  3. Press Ctrl + V on

Here is a small program in Go that demonstrates the issue


package main

import (
	"bufio"
	"io"
	"os"
	"log"

	"golang.org/x/sys/unix"
)

func main() {

	termios, err := unix.IoctlGetTermios(unix.Stdin, unix.TCGETS)
	if err != nil {
		log.Fatalf("could not fetch console settings: %s", err)
	}

	termios.Lflag = termios.Lflag &^ unix.ICANON
	termios.Iflag = termios.Iflag &^ unix.IXON 

	if err := unix.IoctlSetTermios(unix.Stdin, unix.TCSETSF, termios); err != nil {
		log.Fatalf("could not set console settings: %s", err)
	}

	r := bufio.NewReader(os.Stdin)

	for {

		b, err := r.ReadByte()

		if err == io.EOF {
			break
		} else if err != nil {
			log.Fatalf("Error reading from Stdin: %s\n", err)
			os.Exit(1)
		}
		log.Printf("%d\n", b)
	}
}

Expected behavior

Reading Ctrl + V key from keyboard should return 22. This is what happens in the default Ubuntu WSL terminal

Actual behavior

Returns a whole bunch of characters as keypresses

Originally created by @srinathh on GitHub (May 25, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment WSL Ubuntu 20.04 # Steps to reproduce 1. Enter Raw Mode 2. Turn off IEXTEN behavior by using the IXON flag 3. Press Ctrl + V on Here is a small program in Go that demonstrates the issue ```go package main import ( "bufio" "io" "os" "log" "golang.org/x/sys/unix" ) func main() { termios, err := unix.IoctlGetTermios(unix.Stdin, unix.TCGETS) if err != nil { log.Fatalf("could not fetch console settings: %s", err) } termios.Lflag = termios.Lflag &^ unix.ICANON termios.Iflag = termios.Iflag &^ unix.IXON if err := unix.IoctlSetTermios(unix.Stdin, unix.TCSETSF, termios); err != nil { log.Fatalf("could not set console settings: %s", err) } r := bufio.NewReader(os.Stdin) for { b, err := r.ReadByte() if err == io.EOF { break } else if err != nil { log.Fatalf("Error reading from Stdin: %s\n", err) os.Exit(1) } log.Printf("%d\n", b) } } ``` <!-- A description of how to trigger this bug. --> # Expected behavior Reading Ctrl + V key from keyboard should return 22. This is what happens in the default Ubuntu WSL terminal # Actual behavior Returns a whole bunch of characters as keypresses
Author
Owner

@zadjii-msft commented on GitHub (May 26, 2020):

This is probably because Ctrl+V is bound to paste by default for new settings files. You can remove that binding from your settings by just deleting that line from your settings.json. Then, the ^V will get passed through to the commandline application as normal.

@zadjii-msft commented on GitHub (May 26, 2020): This is probably because <kbd>Ctrl+V</kbd> is bound to `paste` by default for new settings files. You can remove that binding from your settings by just deleting that line from your `settings.json`. Then, the `^V` will get passed through to the commandline application as normal.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8578