fix: ttyd dies immediately — add start_new_session=True to subprocess spawn

Without start_new_session=True, ttyd inherits the parent's process group
and gets cleaned up when the asyncio transport is garbage collected after
the HTTP handler completes. start_new_session=True detaches ttyd into
its own process group so it survives independently of the parent.
This commit is contained in:
Brian Krabach
2026-04-01 01:23:07 -07:00
parent 91faab9b94
commit 65b5c3ad20
+1
View File
@@ -213,6 +213,7 @@ async def spawn_ttyd(session_name: str) -> asyncio.subprocess.Process:
session_name, session_name,
stdout=asyncio.subprocess.DEVNULL, stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL, stderr=asyncio.subprocess.DEVNULL,
start_new_session=True, # detach from parent process group so ttyd survives independently
) )
# Write PID file (create parent dirs if needed) # Write PID file (create parent dirs if needed)