@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
29 lines • 2.05 kB
TypeScript
/**
* The spawn's stdio with the startup pipe at `STARTUP_EVENT_FD`, and the slots it had to fill on the way.
*
* Every unused slot from 3 to 15 becomes a FILLER pipe rather than "ignore": on macOS, Node's libuv `uv_spawn`
* calls abort() - killing the spawning process, not the child - when a libuv-created pipe sits at a high slot
* above an unfilled one and the parent has free descriptors below it (reproduced on Node 24 and 26, never on
* Bun). Slots the spawn already uses, including the #4749 private descriptors `spawnWithPrivateFds` places at
* their own numbers afterwards, are left alone. The child never reads a filler: no fd 3..15 is opened by number
* without a flag naming it, and Node marks inherited descriptors close-on-exec, so they end with the child.
* Pass the returned `fillers` to `releaseStartupFillers` right after the spawn.
*/
export declare function withStartupPipe<T>(base: readonly T[]): {
readonly stdio: (T | "pipe")[];
readonly fillers: number[];
};
/** Closes the parent's end of every filler pipe; a slot a private descriptor took over has no stream. */
export declare function releaseStartupFillers(child: {
readonly stdio: readonly unknown[];
}, fillers: readonly number[]): void;
/**
* Closes the filler pipes this process inherited (they only kept libuv from aborting the spawn that created
* them, see `withStartupPipe`) and removes their list from the hand-off, so a process this one re-executes or
* spawns never closes a descriptor that is not a filler. A slot the #4749 private table names is that
* channel's, never a filler, and stays open. A table that does not decode (the `unparseable` marker included)
* cannot prove any slot free of a channel, so no filler is closed. A slot that no longer holds its filler is
* the runtime's own and stays open (`inheritedFillerCheck`). Called first by every entry that can receive a hand-off.
*/
export declare function releaseInheritedStartupFillers(env: NodeJS.ProcessEnv): void;
//# sourceMappingURL=private-fd-startup-fillers.d.ts.map