Files
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

19 lines
1.0 KiB
Python

"""Capture an owned console process without waiting on descendants' pipe EOF.
Wine services can inherit stdout/stderr beyond the requested executable's exit.
Private regular files keep completion tied to that process, with bounded output.
No arguments, environment or output are logged by this helper.
"""
import os
import subprocess
import tempfile
def run_console(arguments,*,env=None,timeout=15,limit=1048576):
if not 1<=limit<=1048576:raise ValueError('Console capture bound')
with tempfile.TemporaryFile() as out,tempfile.TemporaryFile() as error:
result=subprocess.run(arguments,env=env,stdin=subprocess.DEVNULL,stdout=out,stderr=error,timeout=timeout)
# pread avoids changing file offsets shared with still-running services.
stdout=os.pread(out.fileno(),limit+1,0);stderr=os.pread(error.fileno(),limit+1,0)
if len(stdout)>limit or len(stderr)>limit:raise RuntimeError('Owned console output exceeded capture bound')
return subprocess.CompletedProcess(arguments,result.returncode,stdout,stderr)