diff --git a/agent-node/src/agent_node/main.py b/agent-node/src/agent_node/main.py index 0e891c0..4cba41c 100644 --- a/agent-node/src/agent_node/main.py +++ b/agent-node/src/agent_node/main.py @@ -85,10 +85,11 @@ current_pid = os.getpid() try: - # Use realpath to resolve any symlinks for accurate comparison - my_path = os.path.realpath(__file__) + # Use realpath to resolve any symlinks for accurate comparison. + # normcase is essential for Windows (case-insensitivity and backslashes). + my_path = os.path.normcase(os.path.realpath(__file__)) except: - my_path = os.path.abspath(__file__) + my_path = os.path.normcase(os.path.abspath(__file__)) cleaned = 0 try: @@ -110,12 +111,12 @@ try: # 1. Try absolute path resolution if os.path.isabs(arg): - check_path = os.path.realpath(arg) + check_path = os.path.normcase(os.path.realpath(arg)) else: # 2. Try relative resolution based on the sibling's current working directory try: cwd = proc.cwd() - check_path = os.path.realpath(os.path.join(cwd, arg)) + check_path = os.path.normcase(os.path.realpath(os.path.join(cwd, arg))) except (psutil.AccessDenied, psutil.NoSuchProcess): # If we can't get the CWD of the other process, we rely on a direct name match # but stay conservative to avoid killing unrelated processes. @@ -182,11 +183,8 @@ # 0. Singleton Enforcement: Murder siblings before booting try: import psutil - if os.name != 'nt': - print("[*] Running singleton check...") - enforce_singleton() - else: - print("[*] Skipping singleton check on Windows...") + print("[*] Running singleton check...") + enforce_singleton() except Exception as e: print(f"[!] Singleton check failed: {e}") traceback.print_exc()