From 9cc27becffeba0e117fea26aa5c2e1fe7afc6e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=B0=B8=E8=B5=AB?= <1259085392@qq.com> Date: Tue, 10 Feb 2026 17:18:33 +0900 Subject: [PATCH] fix: use execv for stable backend reboot args --- astrbot/core/updator.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/astrbot/core/updator.py b/astrbot/core/updator.py index 87268c609..784745de5 100644 --- a/astrbot/core/updator.py +++ b/astrbot/core/updator.py @@ -51,28 +51,22 @@ class AstrBotUpdator(RepoZipUpdator): """ time.sleep(delay) self.terminate_child_processes() - if os.name == "nt": - py = f'"{sys.executable}"' - else: - py = sys.executable + executable = sys.executable try: # 仅 CLI 模式走 `python -m astrbot.cli.__main__`, # 打包后的后端可执行文件需要直接 exec 自身。 if os.environ.get("ASTRBOT_CLI") == "1": - if os.name == "nt": - args = [f'"{arg}"' if " " in arg else arg for arg in sys.argv[1:]] - else: - args = sys.argv[1:] - os.execl(sys.executable, py, "-m", "astrbot.cli.__main__", *args) + args = sys.argv[1:] + os.execv(executable, [executable, "-m", "astrbot.cli.__main__", *args]) else: if getattr(sys, "frozen", False): # Frozen executable should not receive argv[0] as a positional argument. - os.execl(sys.executable, py, *sys.argv[1:]) + os.execv(executable, [executable, *sys.argv[1:]]) else: - os.execl(sys.executable, py, *sys.argv) + os.execv(executable, [executable, *sys.argv]) except Exception as e: - logger.error(f"重启失败({py}, {e}),请尝试手动重启。") + logger.error(f"重启失败({executable}, {e}),请尝试手动重启。") raise e async def check_update(