How to run an external program with RunCommandLoop, while interacting with it? lazarus / 21-General ---------------------------------------------------------------------- vsajip · 2025-06-15 06:39 I want to run an external program and interact with it, but I can't seem to do that with the built-in TProcess.RunCommandLoop functionality. That's because of this loop in TProcess.RunCommandLoop: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     while Running do      begin        // Only call ReadFromStream if Data from corresponding stream        // is already available, otherwise, on  linux, the read call        // is blocking, and thus it is not possible to be sure to handle        // big data amounts bboth on output and stderr pipes. PM.        gotoutput:=ReadInputStream(output, BytesRead,OutputLength,OutputString,1);        // The check for assigned(P.stderr) is mainly here so that        // if we use poStderrToOutput in p.Options, we do not access invalid memory.      gotoutputstderr:=false;        if assigned(stderr) then            got outputstderr:=ReadInputStream(StdErr,StdErrBytesRead,StdErrLength,StdE rrString,1);         if (porunidle in options) and not gotoutput and not gotoutputstderr and Assigned(FOnRunCommandEvent) Then          FOnRunCommandEvent(self,Nil,RunCommandIdle,'');      end; Now, I do have poRunIdle in my options, and have assigned OnRunCommandEvent to a handler, but specifically due to the checks for gotoutput and gotoutputstderr, my handler isn't being called. I know I can subclass TProcess and override RunCommandLoop, but is there another way which is simpler? Also, I see that TRunCommandEventCode has options RunCommandReadOutputString and RunCommandReadOutputStream, but how are these supposed to be used? I see no usages of them in the Lazarus source code. ---------------------------------------------------------------------- Leledumbo · 2025-06-16 15:00 RunCommandLoop is not meant for interactivity. You really need to replicate this while Running loop with your own body. ---------------------------------------------------------------------- vsajip · 2025-06-17 10:03 Quote from: Leledumbo on June 16, 2025, 05:00:21 pmRunCommandLoop is not meant for interactivity. You really need to replicate this while Running loop with your own body. Shame. I've done that, thanks. I just wondered if there was a simpler way, but it appears not. ---------------------------------------------------------------------- Thaddy · 2025-06-17 10:42 Haver a look at TAsyncProcess. That comes very close to what you want. ---------------------------------------------------------------------- vsajip · 2025-06-18 06:50 Thanks for the tip.