FpDebug: fix reading pty for console window.

This commit is contained in:
Martin 2024-02-10 22:12:52 +01:00
parent fcd6d0493d
commit 47c34d2e7e

View File

@ -1435,18 +1435,22 @@ function TDbgLinuxProcess.GetConsoleOutput: string;
var var
ABytesAvailable: DWord; ABytesAvailable: DWord;
ABytesRead: cint; ABytesRead: cint;
s: string;
begin begin
if fpioctl(FMasterPtyFd, FIONREAD, @ABytesAvailable)<0 then if fpioctl(FMasterPtyFd, FIONREAD, @ABytesAvailable)<0 then
ABytesAvailable := 0; ABytesAvailable := 0;
if ABytesAvailable>0 then
begin
setlength(result, ABytesAvailable);
ABytesRead := fpRead(FMasterPtyFd, result[1], ABytesAvailable);
SetLength(result, ABytesRead);
end
else
result := ''; result := '';
while ABytesAvailable>0 do
begin
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; end;
procedure TDbgLinuxProcess.SendConsoleInput(AString: string); procedure TDbgLinuxProcess.SendConsoleInput(AString: string);