Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce likelihood of races between stdout and cooked stdin reads #18326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Dec 13, 2024

As explained in the comment on _getViewportCursorPosition, printing
to stdout after initiating a cooked stdin reads is a race condition
between the application and the terminal. But we can significantly
reduce the likelihood of this being obvious with this change.

Related to #18265
Possibly related to #18081

Validation Steps Performed

Execute the following Go code and start typing:

package main

import (
	"fmt"
	"time"
)

func main() {
	go func() {
		time.Sleep(50 * time.Millisecond)
		fmt.Printf("Here is a prompt! >")
	}()

	var text string
	fmt.Scanln(&text)
}

Without this change the prompt will disappear,
and with this change in place, it'll work as expected. ✅

@lhecker lhecker added the Area-CookedRead The cmd.exe COOKED_READ handling label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CookedRead The cmd.exe COOKED_READ handling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant