SparkyCracked
SparkyCracked
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
I'll def look into it as soon as I have some time (my git profile is even looking horrendous lmao)
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
Yo wassup man. Yeah it's such a nieche issue. I honestly haven't even played around with this recently. I've been so busy it's crazy
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
i capped myself to 45 min yesterday on working on it, still at the same place. Will look into it today again.
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
Yoo wassup
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
Ok @Abdesol I can't lie, it may take me some time to figure this out. I managed to get it to the point where it exits the cloning process when done and waits for input again by itself but the actual printing of output is a little tougher. I don't understand the reason it is bombing out as of yet
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
@Abdesol Some progress... I've located a potential issue where the output capturing from the process in C# is not handling the asynchronous nature of the git clone operation correctly. It's super weird so I am gonna try see if I can read the outputs properly and prevent early termination of the process (I mean git still clones cause my massive project managed to clone so it works which is good)
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
Ok cool
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
You can use the above link
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
$code
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
Ohh fair, if you comfortable with that...
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
For me I want to see if you ever have more than that one in your code at any point. So when you step in your code, once you print out 'Cloning into...' hover over the variable and see what it's contents are
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
I've recently been diving deep into tasks and threading so yeah
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
Here is some documentation on race conditions
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
There might be a potential race condition where the process exits before all output has been read. To mitigate this, consider awaiting the I/O tasks before awaiting process.WaitForExitAsync(). This ensures that all output is captured even if the process exits quickly:
c#
var outputTask = OutputToConsole(process.StandardOutput, process);
var errorTask = OutputToConsole(process.StandardError, process);
var inputTask = InputToProcess(process);

await Task.WhenAll(outputTask, errorTask, inputTask);
await process.WaitForExitAsync();
c#
var outputTask = OutputToConsole(process.StandardOutput, process);
var errorTask = OutputToConsole(process.StandardError, process);
var inputTask = InputToProcess(process);

await Task.WhenAll(outputTask, errorTask, inputTask);
await process.WaitForExitAsync();
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
It looks fine from my side, I don't see any issues
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
It just ended?
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
Yeah...tough. Are you able to get the raw outputs? Put a break and see what the variables are
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
For the git I can give you some code as I have done this before:
c#
StringBuilder currentLine = new StringBuilder();
while (!reader.EndOfStream || !process.HasExited)
{
int c = reader.Read();
if (c == -1) { if (process.HasExited) break; else continue; }

char ch = (char)c;
if (ch == '\r') {
Console.Write(currentLine.ToString());
Console.Write('\r');
currentLine.Clear();
} else if (ch == '\n') {
Console.WriteLine(currentLine.ToString());
currentLine.Clear();
} else {
currentLine.Append(ch);
}
}
if (currentLine.Length > 0)
Console.WriteLine(currentLine.ToString());
c#
StringBuilder currentLine = new StringBuilder();
while (!reader.EndOfStream || !process.HasExited)
{
int c = reader.Read();
if (c == -1) { if (process.HasExited) break; else continue; }

char ch = (char)c;
if (ch == '\r') {
Console.Write(currentLine.ToString());
Console.Write('\r');
currentLine.Clear();
} else if (ch == '\n') {
Console.WriteLine(currentLine.ToString());
currentLine.Clear();
} else {
currentLine.Append(ch);
}
}
if (currentLine.Length > 0)
Console.WriteLine(currentLine.ToString());
So you basically checking characters and when it finds the \r it will then reset the line buffer.
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
busy typing lol, I take some time give me a minute lol.
82 replies
CC#
Created by Abdesol on 7/4/2024 in #help
standard output from Process not giving any output for certain commands
With regards to git clone, commands like that output progress dynamically by rewriting lines. It uses \r as carriage returns intend of \n and some standard output redirects may not handle that well. So you can either read raw output (which I like to do most of the time) and when you detect \r then treat it as an instruction to overwrite the current line in your output display.
82 replies