C#C
C#2y ago
Abdesol

standard output from Process not giving any output for certain commands

I am using C# process to run some processes. The shell is cmd.exe, and running several types of scripts work. But, when I try to run python idle with the command cmd.exe /C python, it is giving no output and the process is also not exiting. It should have displayed the idle texts like it do on a normal terminal.
The task function in which I am writing the output:
async Task OutputToConsole(StreamReader reader, Process process)
{
    var buffer = new char[128];
    while (true)
    {
        var read = await reader.ReadAsync(buffer, 0, buffer.Length);
        if (read > 0)
        {
            var output = new string(buffer, 0, read);
            Console.Write(output);
        }

        if (process.HasExited && read == 0) break;
    }
}


Is my approach wrong? Thank you!
Was this page helpful?