Skip to content

Commit b961071

Browse files
committed
Having the checkpipe option to false, it was breaking the routine
Former-commit-id: 27183f18fecdaed2e7366a81fd3fe84a6f410289 [formerly 6e30b05d330d4108f8166c03736ac7fa37eaeda6] [formerly 3532499 [formerly 3532499 [formerly 5e9beda]]] Former-commit-id: ed6a580046caf3f10f89a645908ac5fb2cb687c4 [formerly 27938252c2ed7cca69d1274619c34891d8632077] Former-commit-id: b41a3bbb6a386a65b0abd3df7a8af2615cfccd29 Former-commit-id: e187cc9
1 parent b37b349 commit b961071

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/Tools/PyTools.ExecCmd.Win.pas

Lines changed: 9 additions & 8 deletions
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)