Skip to content

Commit 5e9beda

Browse files
committed
Having the checkpipe option to false, it was breaking the routine
1 parent 34207b0 commit 5e9beda

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/Tools/PyTools.ExecCmd.Win.pas

+9-8
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ procedure TExecCmd.Redirect(out AReader: TReader; out AWriter: TWriter);
181181

182182
while GetIsAlive() and Result.IsEmpty() do begin
183183
Result := Result + PeekMessage();
184+
Sleep(100);
184185
end;
185186

186187
if not Result.IsEmpty() then
@@ -290,15 +291,15 @@ function TExecCmd.PeekMessage(const ACheckPipe: boolean): string;
290291
begin
291292
Result := String.Empty;
292293

293-
if ACheckPipe and not PeekNamedPipe(FStdOutPipeRead, nil, 0, nil, @LBytesRead, nil) then
294-
Exit;
294+
if ACheckPipe then
295+
if not PeekNamedPipe(FStdOutPipeRead, nil, 0, nil, @LBytesRead, nil)
296+
or (LBytesRead = 0) then
297+
Exit;
295298

296-
if (LBytesRead > 0) then
297-
if ReadFile(FStdOutPipeRead, LBuffer, BUFFSIZE, LBytesRead, nil) then
298-
if (LBytesRead > 0) then begin
299-
LBuffer[LBytesRead] := #0;
300-
Result := Result + String(LBuffer);
301-
end;
299+
if ReadFile(FStdOutPipeRead, LBuffer, BUFFSIZE, LBytesRead, nil) then
300+
if (LBytesRead > 0) then begin
301+
SetString(Result, LBuffer, LBytesRead);
302+
end;
302303
end;
303304

304305
end.

0 commit comments

Comments
 (0)