pi-mono/packages/coding-agent/native/win32
Petr Houška 4e10d73400 fix(coding-agent): kill whole process trees of bash commands on Windows
taskkill /T finds descendants through their parent pid, so it missed
background processes whose shell had already exited and processes started
by intermediate processes that exited. Commands now run in a named job
object created by a bundled helper (pi-job.exe, plain C, kernel32 only,
x64 and arm64 prebuilds built like packages/tui/native/win32). Abort and
timeout terminate the job. Background processes left when a command
finishes keep running in the job, held by a detached holder process, as
they do on Unix.
2026-11-05 23:36:31 +01:00
..
prebuilds fix(coding-agent): kill whole process trees of bash commands on Windows 2026-11-05 23:36:31 +01:00
src fix(coding-agent): kill whole process trees of bash commands on Windows 2026-11-05 23:36:31 +01:00
build.mjs fix(coding-agent): kill whole process trees of bash commands on Windows 2026-11-05 23:36:31 +01:00
README.md fix(coding-agent): kill whole process trees of bash commands on Windows 2026-11-05 23:36:31 +01:00

Windows native prebuilds

pi-job.exe runs the bash and PowerShell tools' commands in a named job object, so pi can kill a command's whole process tree on abort or timeout, including background processes whose parent shell already exited (taskkill /T cannot find those). Background processes left when a command finishes keep running, as they do on Unix. See the header of src/pi-job.c for the modes. Links to kernel32 only, without the C runtime.

Building

On Windows, install Visual Studio's "Desktop development with C++" workload, then run from the repository root to build x64 and arm64:

npm --prefix packages/coding-agent run build:native:win32

For cross-builds or custom toolchains, provide MinGW-compatible compilers (for example llvm-mingw, which targets both):

PI_WIN32_TOOLCHAIN=mingw \
CC_X64=/path/to/x86_64-w64-mingw32-clang \
CC_ARM64=/path/to/aarch64-w64-mingw32-clang \
npm --prefix packages/coding-agent run build:native:win32