Skip to content

ReadFileOutputWindows() loops forever #1

@Jaj0

Description

@Jaj0

Hello im using function CmdRunner.ExecuteCommandWithStringResult("cm cat " + elem, Environment.CurrentDirectory) to get file from my repo. For some files i observed infinite loop, when my program hangs. During debugging i found that program constantly executes this line of code:

while (!TryToOpenFile(outputfile, ref sreader) && !proc.HasExited)
                {
                    result = RunWait(
                        proc, initWait,
                        ref lastElapsed,
                        ref totSeconds,
                        out error);

                    if (result != 0)
                        return result;
                }

in ReadFileOutputWindows() function in CodiceCmdRunner.cs

Further debugging showed me that line which causes this issue is this one:

if (line.StartsWith(COMMAND_RESULT))

when i observed last line of file i saw

}CommandResult 0

this bracket at beggining of line is last line of my file (just close bracket from some function from above). Due to this bracket at the beginning, bDone flag was never set to true and program went to infinite loop. So i swapped if (line.StartsWith(COMMAND_RESULT)) with if (line.Containd(COMMAND_RESULT)) and everything started to work correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions