← Catalog

@hcflabs/pi-process

Bounded UTF-8 child-process execution for Pi packages.

Package

Install

Install with PiG

pig install npm:@hcflabs/pi-process

Install with Pi

pi install npm:@hcflabs/pi-process
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

README

Written by the package's publisher, shown as published in version 0.3.0 (README.md). PiG does not review it.

@hcflabs/pi-process

Run one argv-only child process. Limit UTF-8 output and execution time. Cancel the process when necessary.

Install

npm install @hcflabs/pi-process

Use

import { spawnBounded } from "@hcflabs/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. Pass timeoutMs: null for a process without an elapsed-time limit. Cancellation and output limits still apply.

Each output stream has a 64 KiB limit. Set stdoutTailBytes to keep only the end of stdout instead of applying the stdout limit. The retained text has complete UTF-8 characters.

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

API

SurfaceTypePurpose
spawnBoundedfunctionRun one bounded argv-only child process.
ExectypeDescribe the executor call signature.
ExecOptionstypeConfigure cwd, cancellation, timeout, limits, and string stdin.
ExecResulttypeReturn stdout, stderr, exit code, kill state, and tail truncation.
scanProcessLeasefunctionRun lsof on a private lease file and return the PIDs that hold it open. An empty result is evidence that the leased processes stopped.
assertPrivateLeasefunctionRequire a current-user, regular, non-symlink, mode-0600 lease file.