[SOLVED] Improvement of function TProcess.Terminate lazarus / 64-FPC development ---------------------------------------------------------------------- lagprogramming · 2023-07-19 10:14 packages/fcl-process/src/unix/process.inc has the following function: 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 TProcess.Terminate(AExitCode : Integer) : Boolean; begin  Result:=False;  Result:=fpkill(Handle,SIGTERM)=0;  If Result then    begin    If Running then      Result:=fpkill(Handle,SIGKILL)=0;    end;  { the fact that the signal has been sent does not    mean that the process has already handled the    signal -> wait instead of calling getexitstatus }  if Result then    WaitOnExit;end;The initial Result:=False; line has been removed. After that, the code has been changed so that the condition to call WaitOnExit is executed depending on If Running then Result:=fpkill(Handle,SIGKILL)=0; The code becomes: 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 TProcess.Terminate(AExitCode : Integer) : Boolean; begin  Result:=fpkill(Handle,SIGTERM)=0;  If Result then    begin      If Running then        begin          Result:=fpkill(Handle,SIGKILL)=0;        if not Result then exit;        end;      { the fact that the signal has been sent does not      mean that the process has already handled the      signal -> wait instead of calling getexitstatus }    WaitOnExit;    end;end; Here is the patch 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 diff --git a/packages/fcl-process/src/unix/process.inc b/packages/fcl- process/src/unix/process.incindex 54c00ef8ea..7099ca8339 100644--- a/packages/fcl-process/src/unix/process.inc+++ b/packages/fcl- process/src/unix/process.inc@@ -530,18 +530,19 @@ procedure TProcess.CloseProcessHandles; Function TProcess.Terminate(AExitCode : Integer) : Boolean;  begin-  Result:=False;   Result:=fpkill(Handle,SIGTERM)=0;   If Result then     begin-    If Running then-      Result:=fpkill(Handle,SIGKILL)=0;+      If Running then+        begin+          Result:=fpkill(Handle,SIGKILL)=0;+        if not Result then exit;+        end;+      { the fact that the signal has been sent does not+      mean that the process has already handled the+      signal -> wait instead of calling getexitstatus }+    WaitOnExit;     end;-  { the fact that the signal has been sent does not-    mean that the process has already handled the-    signal -> wait instead of calling getexitstatus }-  if Result then-    WaitOnExit; end;  Procedure TProcess.SetShowWindow (Value : TShowWindowOptions); ---------------------------------------------------------------------- AlexTP · 2023-07-19 10:24 Posted to https://gitlab.com/freepascal.org/fpc/source/-/issues/40356