© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
81 replies
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
cmd.exe
, and running several types of scripts work. But, when I try to run python idle with the command
cmd.exe /C python
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;
    }
}
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!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ Capturing process output
C#CC# / help
3y ago
❔ Capturing process output
C#CC# / help
3y ago
✅ How read text output from already started process?
C#CC# / help
3y ago