Runcommandloop polls the pipes again after the process is terminated to make sure.
That is TProcess? The debugger (both fpdebug and gdb) don't use the processes internal pipes. In case of gdb that would be the communication with gdb anyway. In both cases, the output of the child process is redirected to a virtual pty.
And that is then polled inside the debugger-backend.
But yes there is one last poll in FpDebug, after the app exited.
procedure TFpDebugDebugger.FDbgControllerProcessExitEvent(AExitCode: DWord);
...
AThread.DoHasConsoleOutput(0);
procedure TFpWaitForConsoleOutputThread.DoHasConsoleOutput(Data: PtrInt);
...
s := FFpDebugDebugger.FDbgController.CurrentProcess.GetConsoleOutput;
function TDbgLinuxProcess.GetConsoleOutput: string;
...
if fpioctl(FMasterPtyFd, FIONREAD, @ABytesAvailable)<0 then
...
ABytesRead := fpRead(FMasterPtyFd, result[1], ABytesAvailable);
That does leave 2 questions though.
1) How fast does the pty work?
2) Does such a read guarantee to read everything available, or should it be called several times until no further data was read.
One other test would be to add a sleep into the code above FDbgControllerProcessExitEvent before the call to do the read.
That would test if there is any delay.
If only part of the data may be read, then a loop in DoHasConsoleOutput ( "repeat ... until (data <> 0) or (s = ''); " )
On the "thread" discussion....
My reading about the original post by jollytall is that all references to "thread" are assumptions of threads running in the Lazarus IDE?
And that the app that jollytall runs does not itself uses threads (or if it does only his main thread does interact with StdOut)?
@jollytall Can you explicitly confirm this? (I am not sure about your last reply on threading).