---
title: "@henryqw/pi-process"
seo:
  description: "Bounded UTF-8 child-process execution for Pi packages."
---

<div class="not-prose my-6 flex flex-wrap items-center gap-3"><a href="https://www.npmjs.com/package/@henryqw/pi-process" aria-label="View @henryqw/pi-process version v0.1.0 on npm"><img alt="Version v0.1.0" height="20" src="https://img.shields.io/static/v1?cacheSeconds=7200&amp;color=1d4ed8&amp;label=version&amp;labelColor=6a7282&amp;style=flat-square&amp;message=v0.1.0" width="96"></a><div class="ml-auto flex flex-wrap items-center justify-end gap-3"><a href="https://www.npmjs.com/package/@henryqw/pi-process" aria-label="View @henryqw/pi-process on npm"><img alt="Monthly npm downloads" height="20" src="https://img.shields.io/npm/dm/%40henryqw%2Fpi-process?cacheSeconds=7200&amp;color=1d4ed8&amp;label=downloads&amp;labelColor=6a7282&amp;style=flat-square" width="144"></a><a href="https://github.com/HenryQW/pi-harness/blob/main/packages/pi-process/LICENSE" aria-label="View the MIT license for @henryqw/pi-process"><img alt="MIT license" height="20" src="https://img.shields.io/npm/l/%40henryqw%2Fpi-process?cacheSeconds=7200&amp;color=1d4ed8&amp;label=license&amp;labelColor=6a7282&amp;style=flat-square" width="78"></a></div></div>

Run one argv-only child process with bounded UTF-8 output, cancellation, and a timeout.

## Install

```bash
npm install @henryqw/pi-process
```

## Use

```ts
import { spawnBounded } from "@henryqw/pi-process";

const result = await spawnBounded("git", ["status"], { cwd: process.cwd() });
if (result.code !== 0 || result.killed) throw new Error(result.stderr);
```

`spawnBounded` accepts an optional UTF-8 string on stdin. It strictly decodes stdout and stderr. The default timeout is 30 seconds, and each output stream is limited to 64 KiB. Set `stdoutTailBytes` to retain a UTF-8-safe tail instead of applying the stdout limit.

On POSIX systems, cancellation and timeout terminate the child process group. Invalid command, argument, and working-directory values fail before a child starts.

## API

| Surface | Type | Purpose |
| --- | --- | --- |
| `spawnBounded` | function | Run one bounded argv-only child process. |
| `Exec` | type | Describe the executor call signature. |
| `ExecOptions` | type | Configure cwd, cancellation, timeout, limits, and string stdin. |
| `ExecResult` | type | Return stdout, stderr, exit code, kill state, and tail truncation. |
