From 5858a84ae21d166dc3e238f16485019b4c09ce84 Mon Sep 17 00:00:00 2001 From: jcteng Date: Wed, 23 Nov 2022 05:32:00 +0800 Subject: [PATCH] Windows: start daemon without a window and detached from current console (#9697) Co-authored-by: Earle Lowe <30607889+emlowe@users.noreply.github.com> Co-authored-by: Earle Lowe --- chia/cmds/start_funcs.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/chia/cmds/start_funcs.py b/chia/cmds/start_funcs.py index ed33b80f9f66..41aea357b1c2 100644 --- a/chia/cmds/start_funcs.py +++ b/chia/cmds/start_funcs.py @@ -17,8 +17,17 @@ from chia.util.service_groups import services_for_groups def launch_start_daemon(root_path: Path) -> subprocess.Popen: os.environ["CHIA_ROOT"] = str(root_path) - # TODO: use startupinfo=subprocess.DETACHED_PROCESS on windows - process = subprocess.Popen([sys.argv[0], "run_daemon", "--wait-for-unlock"], stdout=subprocess.PIPE) + creationflags = 0 + if sys.platform == "win32": + creationflags = subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_NO_WINDOW + + process = subprocess.Popen( + [sys.argv[0], "run_daemon", "--wait-for-unlock"], + encoding="utf-8", + stdout=subprocess.PIPE, + creationflags=creationflags, + ) + return process