From 47c34d2e7ea0356f0b101becc5df8cc311e8c4cd Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 10 Feb 2024 22:12:52 +0100 Subject: [PATCH] FpDebug: fix reading pty for console window. --- components/fpdebug/fpdbglinuxclasses.pas | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/components/fpdebug/fpdbglinuxclasses.pas b/components/fpdebug/fpdbglinuxclasses.pas index cb1b17c711..47f1c1fe7b 100644 --- a/components/fpdebug/fpdbglinuxclasses.pas +++ b/components/fpdebug/fpdbglinuxclasses.pas @@ -1435,18 +1435,22 @@ function TDbgLinuxProcess.GetConsoleOutput: string; var ABytesAvailable: DWord; ABytesRead: cint; + s: string; begin if fpioctl(FMasterPtyFd, FIONREAD, @ABytesAvailable)<0 then ABytesAvailable := 0; - if ABytesAvailable>0 then + result := ''; + while ABytesAvailable>0 do begin - setlength(result, ABytesAvailable); - ABytesRead := fpRead(FMasterPtyFd, result[1], ABytesAvailable); - SetLength(result, ABytesRead); - end - else - result := ''; + setlength(s, ABytesAvailable); + ABytesRead := fpRead(FMasterPtyFd, s[1], ABytesAvailable); + SetLength(s, ABytesRead); + Result := Result + s; + + if fpioctl(FMasterPtyFd, FIONREAD, @ABytesAvailable)<0 then + ABytesAvailable := 0; + end; end; procedure TDbgLinuxProcess.SendConsoleInput(AString: string);