From 7d23eef729504ae0d3875592e7a0626830b18ccd Mon Sep 17 00:00:00 2001 From: himanshupatro-334 Date: Tue, 28 Jul 2026 11:38:54 +0530 Subject: [PATCH 1/2] fix(hooks): replace DETACHED_PROCESS with CREATE_NO_WINDOW on Windows --- .gitattributes | 1 + graphify/hooks.py | 4 ++-- tests/test_hooks.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index faa0f4b26..e187e861f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,4 @@ worked/**/*.html linguist-vendored=true graphify-out/**/*.html linguist-vendored=true *.html linguist-detectable=false +graphify-out/graph.json merge=graphify diff --git a/graphify/hooks.py b/graphify/hooks.py index b121b6896..84d3e9b85 100644 --- a/graphify/hooks.py +++ b/graphify/hooks.py @@ -215,7 +215,7 @@ def _bail(): # requires Python, so we let Python do the detaching: a tiny outer process spawns # the real rebuild fully detached and returns immediately, so the hook never # blocks. POSIX uses start_new_session (the setsid equivalent); Windows uses -# DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, breaking away from any job object +# CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP, breaking away from any job object # when allowed. This payload is carried inside a shell double-quoted -c argument, # so it deliberately uses only single-quoted Python strings (no ", $, ` or \\). _LAUNCHER_TEMPLATE = """\ @@ -232,7 +232,7 @@ def _bail(): _kw = dict(stdout=_out, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, cwd=os.getcwd(), close_fds=True) _cmd = [sys.executable, '-c', _src] if os.name == 'nt': - _flags = 0x00000008 | 0x00000200 # DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP + _flags = 0x08000000 | 0x00000200 # CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP try: subprocess.Popen(_cmd, creationflags=_flags | 0x01000000, **_kw) # + CREATE_BREAKAWAY_FROM_JOB except OSError: diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 29acc9ead..37f5e0b2c 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -248,10 +248,10 @@ def test_hooks_do_not_use_nohup(name, script): @pytest.mark.parametrize("name,script", _HOOK_SCRIPTS) def test_hooks_use_cross_platform_detach(name, script): """The replacement detaches via Python: start_new_session on POSIX and - DETACHED_PROCESS|CREATE_NEW_PROCESS_GROUP on Windows (#1161).""" + CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP on Windows (#1161).""" assert "subprocess.Popen" in script assert "start_new_session=True" in script, f"{name} missing POSIX detach" - assert "0x00000008" in script, f"{name} missing Windows DETACHED_PROCESS flag" + assert "0x08000000" in script, f"{name} missing Windows CREATE_NO_WINDOW flag" assert "0x00000200" in script, f"{name} missing CREATE_NEW_PROCESS_GROUP flag" From 77f881528e82b768aff64eb97811bde40cbc20ca Mon Sep 17 00:00:00 2001 From: himanshupatro-334 Date: Tue, 28 Jul 2026 11:45:15 +0530 Subject: [PATCH 2/2] test(hooks): update comment to refer to #2253 --- .gitattributes | 1 - tests/test_hooks.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index e187e861f..faa0f4b26 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,4 +4,3 @@ worked/**/*.html linguist-vendored=true graphify-out/**/*.html linguist-vendored=true *.html linguist-detectable=false -graphify-out/graph.json merge=graphify diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 37f5e0b2c..18c2b59ce 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -248,7 +248,7 @@ def test_hooks_do_not_use_nohup(name, script): @pytest.mark.parametrize("name,script", _HOOK_SCRIPTS) def test_hooks_use_cross_platform_detach(name, script): """The replacement detaches via Python: start_new_session on POSIX and - CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP on Windows (#1161).""" + CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP on Windows (#1161 / #2253).""" assert "subprocess.Popen" in script assert "start_new_session=True" in script, f"{name} missing POSIX detach" assert "0x08000000" in script, f"{name} missing Windows CREATE_NO_WINDOW flag"