From 4c821d6c775b6e22cce2ab6af3b85e1bc325058a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 8 Apr 2024 11:32:07 +0200 Subject: [PATCH 1/2] detached process of ayon launcher has own console --- client/ayon_core/lib/execute.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/lib/execute.py b/client/ayon_core/lib/execute.py index e89c8f22ee..7e5c85810e 100644 --- a/client/ayon_core/lib/execute.py +++ b/client/ayon_core/lib/execute.py @@ -263,15 +263,23 @@ def run_detached_process(args, **kwargs): args = new_args elif low_platform == "windows": - flags = ( - subprocess.CREATE_NEW_PROCESS_GROUP - | subprocess.DETACHED_PROCESS - ) - kwargs["creationflags"] = flags + flags = kwargs.get("creationflags") + if flags is None: + # Create new console if executable is ayon_console, + # otherwise create detached process. + executable_filename = os.path.basename(args[0]).lower() + if executable_filename == "ayon_console.exe": + flags = subprocess.CREATE_NEW_CONSOLE + else: + flags = subprocess.DETACHED_PROCESS + if not sys.stdout: + kwargs["stdout"] = subprocess.DEVNULL + kwargs["stderr"] = subprocess.DEVNULL - if not sys.stdout: - kwargs["stdout"] = subprocess.DEVNULL - kwargs["stderr"] = subprocess.DEVNULL + # New process will become new process group + flags |= subprocess.CREATE_NEW_PROCESS_GROUP + + kwargs["creationflags"] = flags elif low_platform == "linux" and get_linux_launcher_args() is not None: json_data = { From 25716dab219a18727d8e02256a7466927b65b663 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 8 Apr 2024 11:34:48 +0200 Subject: [PATCH 2/2] change prefix in tmp file --- client/ayon_core/lib/execute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/lib/execute.py b/client/ayon_core/lib/execute.py index 7e5c85810e..307ae39a4d 100644 --- a/client/ayon_core/lib/execute.py +++ b/client/ayon_core/lib/execute.py @@ -287,7 +287,7 @@ def run_detached_process(args, **kwargs): "env": kwargs.pop("env") } json_temp = tempfile.NamedTemporaryFile( - mode="w", prefix="op_app_args", suffix=".json", delete=False + mode="w", prefix="ayon_app_args", suffix=".json", delete=False ) json_temp.close() json_temp_filpath = json_temp.name