-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
After calling the Process program, the console input cannot be displayed on the terminal #43866
Comments
Tagging subscribers to this area: @eiriktsarpalis, @jeffhandley |
I can reproduce this in .NET Core 3.1, but not on .NET 5. Minimal repro: using System;
using System.IO;
using System.Diagnostics;
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
var inputStream = Console.OpenStandardInput();
Console.SetIn(new StreamReader(inputStream));
var process = Process.Start("ls");
process.WaitForExit();
Console.WriteLine("Please enter something first:");
var line = Console.ReadLine();
Console.WriteLine($"read first: {line}");
}
}
} |
Is there an alternative to the 3.x version to solve this problem? |
In my tests I was able to make the issue go away by not setting a custom |
Yes.
You can do something that makes .NET Core turn off echoing (I think getting |
Description
hello, I'm not sure if it is a bug, but it seems to be behaving very strangely. This problem only occurs under
linux
, and thewindow
can run as expected.I call a
git
command throughProcess
, and thenReadKey
(or read input with input stream) from the console. Under Linux, user input is hidden(Similar to password input). I expect user input can be seen on the terminal.I reproduced a minimal example the code is as follows, you can also get the complete project through github repo.
The value of variable
line
will be the value entered in the terminal,The program can get the input value correctly but when the key is pressed, it will become like a password input. In other words the entered characters are not displayed in the terminal, until after pressing Enter, the program can receive the input value.If the function
ListReference
is annotated, it can also run as expected under linux.The same code under windows and linux resulted in different behaviors. This confused me. Did I do something wrong?
Configuration
$ uname -a Linux e3e3b80e6c3c 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Other information
I guess whether it is due to some behavior in Process that affects the Console.
The text was updated successfully, but these errors were encountered: