export type CliInterruptReason = 'sigint' | 'sigterm' | 'sighup' | 'watchdog'; type CliInterruptSignal = 'SIGINT' | 'SIGTERM' | 'SIGHUP'; export interface CliInterruptSource { on(event: CliInterruptSignal, listener: () => void): unknown; removeListener(event: CliInterruptSignal, listener: () => void): unknown; } export interface CliInterruptInputSource { readonly isTTY?: boolean; readonly isRaw?: boolean; readonly readableFlowing?: boolean | null; on(event: 'data', listener: (chunk: unknown) => void): unknown; removeListener(event: 'data', listener: (chunk: unknown) => void): unknown; setRawMode?(enabled: boolean): unknown; pause?(): unknown; } export interface CliInterruptWaiter { /** Resolves on the first stop signal or watchdog timeout. */ readonly result: Promise; /** Release signal handlers after asynchronous finalization has completed. */ dispose(): void; } export interface CliInterruptWaiterOptions { source?: CliInterruptSource; input?: CliInterruptInputSource; /** Called after restoring the terminal when Ctrl+C is pressed again. */ forceExit?: (exitCode: number) => void; } /** Whether a foreground CLI command is currently waiting for this source. */ export declare function hasActiveCliInterruptWaiter(source?: CliInterruptSource): boolean; /** * Keep graceful-stop handlers installed until the caller has finished saving. * * Package runners such as pnpm can deliver SIGINT to the foreground child, * immediately follow it with SIGTERM, then cause SIGHUP when the runner exits * and its pseudo-terminal closes. Resolving on the first signal is not enough: * removing any handler at that point lets a subsequent signal kill the child * during asynchronous artifact finalization. * * On a TTY, Ctrl+C is captured as raw input so the package runner itself stays * alive until the child has saved and restored the terminal. Signal handlers * remain as the graceful-stop path for externally delivered termination. */ export declare function createCliInterruptWaiter(watchdogMs: number, options?: CliInterruptWaiterOptions): CliInterruptWaiter; /** * Wait for one stop request and release the handlers immediately afterwards. * Long-running finalizers should use {@link createCliInterruptWaiter} instead. */ export declare function waitForCliInterrupt(watchdogMs: number, source?: CliInterruptSource, input?: CliInterruptInputSource | undefined): Promise; export {}; //# sourceMappingURL=interrupt.d.ts.map