✅ How is Environment.UserInteractive set on Linux?
I am launching a subprocess from another program on Linux, which then tries to do this:
if (Environment.UserInteractive) Console.ReadKey();
if (Environment.UserInteractive) Console.ReadKey();
which gets ruck on the ReadKey. If I redirect stdin from /dev/null (or a
yes
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.
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.