windows check sandbox status

This commit is contained in:
Nordup 2025-03-19 04:17:48 +04:00
parent 49a2a82c2b
commit b113b92dff

View file

@ -131,25 +131,24 @@ func kill_sandbox_macos() -> void:
func is_sandbox_running() -> bool: func is_sandbox_running() -> bool:
if snbx_pid == 0: return false if snbx_pid == 0: return false
var output = []
match Platform.get_platform(): match Platform.get_platform():
Platform.WINDOWS: Platform.WINDOWS:
var output = [] # tasklist /fi "PID eq 1234" /fi "STATUS eq RUNNING" | findstr 1234
OS.execute("cmd.exe", ["/c", "tasklist", "|", "findstr", snbx_pid], output) OS.execute("cmd.exe", ["/c", "tasklist", "/fi", "PID eq " + str(snbx_pid), "/fi", "STATUS eq RUNNING", "|", "findstr", str(snbx_pid)], output)
Debug.logclr("tasklist: " + str(output), Color.DIM_GRAY)
return not output[0].is_empty() return not output[0].is_empty()
Platform.LINUX_BSD: Platform.LINUX_BSD:
var output = [] # ps -o stat= -p 1234
OS.execute("ps", ["-o", "stat=", "-p", snbx_pid], output) OS.execute("ps", ["-o", "stat=", "-p", snbx_pid], output)
var stat = output[0].replace("\n", "").split(" ")[0] var stat = output[0].replace("\n", "").split(" ")[0]
Debug.logclr("ps: " + stat + " " + str(snbx_pid), Color.DIM_GRAY) Debug.logclr("ps: " + stat + " " + str(snbx_pid), Color.DIM_GRAY)
return not stat.is_empty() and not stat in ["Z", "T"] return not stat.is_empty() and not stat in ["Z", "T"]
Platform.MACOS: Platform.MACOS:
var output = [] # ps -o stat= -p 1234
OS.execute("ps", ["-o", "stat=", "-p", snbx_pid], output) OS.execute("ps", ["-o", "stat=", "-p", snbx_pid], output)
var stat = output[0].replace("\n", "").split(" ")[0] var stat = output[0].replace("\n", "").split(" ")[0]
Debug.logclr("ps: " + stat + " " + str(snbx_pid), Color.DIM_GRAY)
return not stat.is_empty() and not stat in ["Z", "T"] return not stat.is_empty() and not stat in ["Z", "T"]
_: _: