C
C#4w ago
sparr

✅ How is Environment.UserInteractive set on Linux?

I am launching a subprocess from another program on Linux, which then tries to do this:
c#
if (Environment.UserInteractive)
Console.ReadKey();
c#
if (Environment.UserInteractive)
Console.ReadKey();
which gets ruck on the ReadKey. If I redirect stdin from /dev/null (or a yes process, even) then I get this exception: Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read. How is C# checking whether the environment is interactive? I need to override that when creating my subprocess, so it skips this conditional entirely.
8 Replies
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
sparr
sparrOP4w ago
yeah, I just found that :/
sparr
sparrOP4w ago
GitHub
Should we revise implementation of Environment.UserInteractive? · ...
This is currently implemented as return true; but since in 3.0 we're adding UI stacks to .NET Core, maybe we should implement this since this is usually used before popping a UI? The Windows ve...
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
sparr
sparrOP4w ago
The C# code and program aren't mine. I'm trying to work around this behavior from outside.
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX4w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?