How to disable ENABLE_LINE_INPUT in ConPTY? How to call GetConsoleMode for a PseudoConsole? #17599

Open
opened 2026-01-31 05:47:19 +00:00 by claunia · 0 comments
Owner

Originally created by @lonnywong on GitHub (May 30, 2022).

Windows Terminal version

1.12.10982.0

Windows build number

10.0.19043.0

Other Software

https://github.com/UserExistsError/conpty v0.1.0

Is it similar to https://stackoverflow.com/a/11439517/7696611 ?

Steps to reproduce

  • go run conptytest.go
package main

import (
        "bufio"
        "context"
        "fmt"
        "strings"

        "github.com/UserExistsError/conpty"
)

func main() {
        cpty, err := conpty.Start("python3 -c \"import sys; s = sys.stdin.readline(); print(len(s))\"")
        if err != nil {
                fmt.Printf("Failed to spawn a pty:  %v", err)
                return
        }
        defer cpty.Close()

        go func() {
                cpty.Write([]byte(strings.Repeat("A", 3000) + "\r\n"))

                scanner := bufio.NewScanner(cpty)
                for scanner.Scan() {
                        // Should output 3001.
                        // But output 511 in cmd, output 2510 in MSYS2.
                        fmt.Printf("Output: %s\n", scanner.Text())
                }
                if err := scanner.Err(); err != nil {
                        fmt.Println(err)
                }
        }()

        if _, err := cpty.Wait(context.Background()); err != nil {
                fmt.Printf("Error: %v", err)
        }
}

Expected Behavior

Output: 3001

Actual Behavior

Output: 511

Originally created by @lonnywong on GitHub (May 30, 2022). ### Windows Terminal version 1.12.10982.0 ### Windows build number 10.0.19043.0 ### Other Software https://github.com/UserExistsError/conpty v0.1.0 Is it similar to https://stackoverflow.com/a/11439517/7696611 ? ### Steps to reproduce * `go run conptytest.go` ```go package main import ( "bufio" "context" "fmt" "strings" "github.com/UserExistsError/conpty" ) func main() { cpty, err := conpty.Start("python3 -c \"import sys; s = sys.stdin.readline(); print(len(s))\"") if err != nil { fmt.Printf("Failed to spawn a pty: %v", err) return } defer cpty.Close() go func() { cpty.Write([]byte(strings.Repeat("A", 3000) + "\r\n")) scanner := bufio.NewScanner(cpty) for scanner.Scan() { // Should output 3001. // But output 511 in cmd, output 2510 in MSYS2. fmt.Printf("Output: %s\n", scanner.Text()) } if err := scanner.Err(); err != nil { fmt.Println(err) } }() if _, err := cpty.Wait(context.Background()); err != nil { fmt.Printf("Error: %v", err) } } ``` ### Expected Behavior Output: 3001 ### Actual Behavior Output: 511
claunia added the Issue-QuestionNeeds-TriageNeeds-Tag-FixProduct-Conpty labels 2026-01-31 05:47:20 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17599