TProcess EOF - CloseInput lazarus / 66-Unix ---------------------------------------------------------------------- Snify · 2022-02-23 14:37 Hello together I have the following function to "read" a regular string from stdin: 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 function GetStdIn: string;var   tmp: string;begin  result := '';  while not EOF do begin    readln (tmp);    if EOF then begin      result:= result + tmp;    end else begin      result:= result + tmp + LineEnding;    end;  end;end;   The full test program looks like this: 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 begin  writeln (StdErr, 'FIRST ERROR LINE');  writeln ('This line and the following stdin detection is on stdout');  writeln ('Stdin was:', LineEnding, GetStdIn);  writeln (StdErr, 'This is on stderror');  writeln ('Regular stdout again');  // end of programend.                              I am not sure if my function is correct. This works like a charm if I use the above function in a shell like this: 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 printf "row1\nrow2\n..." | ./project1 However when I use the TProcess Class with the WriteInput Method, the process locks. This is what I use to execute my program and try to read and write to the pipes: (some of the code is taken from https://wiki.freepascal.org/Executing_External_Programs) 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 MyProcess             := TProcess.Create(NIL);    MyProcess.Executable    := 'project1'; // the program with the "GetStdIn" functionMyProcess.Options               := MyProcess.Options + [poPassInput, poUsePipes];MyProcess.Execute;mystring                              := 'Hello Lazarus';MyProcess.Input.Write(mystring[1], Length(mystring));MyProcess.CloseInput; // does not trigger EOF?! // NumBytesAvailable is always 0 for output and stderrwhile MyProcess.Running or (MyProcess.Output.NumBytesAvailable > 0) or(MyProcess.Stderr.NumBytesAvailable > 0) dobegin    while MyProcess.Output.NumBytesAvailable > 0 do    begin        ReadCount := Min(512, MyProcess.Output.NumBytesAvailable); //Read up to buffer, not more        MyProcess.Output.Read(CharBuffer, ReadCount);    end;                                    while MyProcess.Stderr.NumBytesAvailable > 0 do    begin        ReadCount := Min(512, MyProcess.Stderr.NumBytesAvailable); //Read up to buffer, not more        MyProcess.Stderr.Read(CharBuffer, ReadCount);    end;end;MyProcess.Free;                                                                              The binary path etc. is simplified here and executes just as it should be. If I remove the whole stdin stuff, it works just fine. Can someone spot my error? Thank you in advance ---------------------------------------------------------------------- Snify · 2022-02-23 14:54 I just figured out the problem. Thank you. I needed to avoid "poPassInput". This causes to use the stdin from the "parent" process instead of it's own stdin.