diff --git a/v2rayN/ServiceLib/Manager/CoreAdminManager.cs b/v2rayN/ServiceLib/Manager/CoreAdminManager.cs index db6d9021..79680c2e 100644 --- a/v2rayN/ServiceLib/Manager/CoreAdminManager.cs +++ b/v2rayN/ServiceLib/Manager/CoreAdminManager.cs @@ -91,6 +91,8 @@ public class CoreAdminManager .ExecuteBufferedAsync(); await UpdateFunc(false, result.StandardOutput.ToString()); + + await Task.Delay(1000); // Wait for a second to ensure the process is killed } catch (Exception ex) { diff --git a/v2rayN/ServiceLib/Sample/kill_as_sudo_linux_sh b/v2rayN/ServiceLib/Sample/kill_as_sudo_linux_sh index 21e17408..392c5c20 100644 --- a/v2rayN/ServiceLib/Sample/kill_as_sudo_linux_sh +++ b/v2rayN/ServiceLib/Sample/kill_as_sudo_linux_sh @@ -66,6 +66,11 @@ kill_children "$PID" echo "Terminating main process: $PID" kill -9 "$PID" 2>/dev/null || true +# Wait a little for process/port resources to be fully released +FINAL_WAIT_SECONDS=1 +echo "Waiting ${FINAL_WAIT_SECONDS}s for resources to settle..." +sleep "$FINAL_WAIT_SECONDS" + echo "============================================" echo "Process $PID and all its children have been terminated" echo "============================================" diff --git a/v2rayN/ServiceLib/Sample/kill_as_sudo_osx_sh b/v2rayN/ServiceLib/Sample/kill_as_sudo_osx_sh index 61160fa2..f0511183 100644 --- a/v2rayN/ServiceLib/Sample/kill_as_sudo_osx_sh +++ b/v2rayN/ServiceLib/Sample/kill_as_sudo_osx_sh @@ -63,6 +63,11 @@ kill_descendants "$PID" echo "Terminating main process: $PID" kill -9 "$PID" 2>/dev/null || true +# Wait a little for process/port resources to be fully released +FINAL_WAIT_SECONDS=1 +echo "Waiting ${FINAL_WAIT_SECONDS}s for resources to settle..." +sleep "$FINAL_WAIT_SECONDS" + echo "============================================" echo "Process $PID and all its descendants have been terminated" echo "============================================"