Open josefpihrt opened 11 months ago
Tagging subscribers to this area: @dotnet/area-system-console See info in area-owners.md if you want to be subscribed.
Author: | josefpihrt |
---|---|
Assignees: | - |
Labels: | `area-System.Console` |
Milestone: | - |
I've tried to reproduce the problem and failed to do so.
namespace ConsoleInputRedirected
{
internal class Program
{
static void Main() => Console.WriteLine($"Console.IsInputRedirected={Console.IsInputRedirected}");
}
}
This issue has been marked needs-author-action
and may be missing some important information.
Thank you for your answer @adamsitnik.
I used your console app and run it in git-bash with following result:
I have the latest version of git (2.43.0) so the only difference between yours and mine configuration could be the operation system. I have Windows 10 Pro 10.0.19045.
@josefpihrt Is there any chance you could debug it? You could add System.Diagnostics.Debugger.Launch();
and step into framework code with F11.
I am mostly interested in what happens here:
I was able to debug the process, here are the results:
IsHandleRedirected
returns true:
fileType
is 3global::Interop.Kernel32.IsGetConsoleModeCallSuccessful(handle)
returns false
GetConsoleMode
returns false
:
lastSystemError
is 6Let me know if you need more data.
@adamsitnik ping
The behavior might depend on whether Git Bash is using the Windows pseudoconsole feature (MSYS=enable_pcon
in git-bash.config
).
Description
Hi,
I have command-line tool (roslynator) that tries to read redirected input and use it as an input for the program (in my case it's a list of solutions to be analyzed).
Example code:
For this purpose I use
Console.IsInputRedirected
which works fine on Windows Terminal with Powershell.The problem is that when I run just
roslynator analyze
on git bash (git-bash.exe
)Console.IsInputRedirected
returns true and then the execution is blocked when program tries to read input from console (when there is no redirected input):https://github.com/dotnet/roslynator/blob/e030192b1dc5359df48e5dd15af79b5c807f481c/src/CommandLine/ConsoleHelpers.cs#L20
Thanks for help in advance.
Reproduction Steps
dotnet tool install roslynator.dotnet.cli -g --version 0.7.2
git-bash.exe
from git installation folderroslynator analyze <PATH-TO-SOLUTION> -v diag
Expected behavior
Console.IsInputRedirected should return false when there is no redirected input
Actual behavior
Console.IsInputRedirected returns true on git bash when there is no redirected input.
Regression?
No response
Known Workarounds
Set timeout for a task that tries to read redirected input:
Configuration
Other information
No response