import type { SmartExit } from './smartexit.classes.smartexit.js'; export interface ILifecycleOptions { /** Which signals to intercept. Default: ['SIGINT', 'SIGTERM'] */ signals?: Array<'SIGINT' | 'SIGTERM' | 'SIGHUP'>; /** Handle uncaughtException. Default: true */ uncaughtExceptions?: boolean; /** Max time in ms for graceful shutdown before force-kill. Default: 10000 */ shutdownTimeoutMs?: number; /** Disable lifecycle logging. Default: false */ silent?: boolean; } /** * Global process lifecycle manager. * * Call `ProcessLifecycle.install()` ONCE from your application entry point. * Libraries should NEVER call install() — they just create SmartExit instances. * * All SmartExit instances auto-register here. On shutdown, all instances' * cleanup functions run and all tracked process trees are killed. */ export declare class ProcessLifecycle { private static instance; private static readonly registry; private static exitHandlerInstalled; private options; private shuttingDown; private signalCount; private constructor(); /** * Install global signal handlers. * Call ONCE from the application entry point. Libraries should NOT call this. * Idempotent — subsequent calls return the existing instance. */ static install(options?: ILifecycleOptions): ProcessLifecycle; /** Get the installed lifecycle, or null if not installed. */ static getInstance(): ProcessLifecycle | null; /** Check whether global handlers are installed. */ static isInstalled(): boolean; /** Called by SmartExit constructor to auto-register. */ static registerInstance(instance: SmartExit): void; /** Remove an instance from the global registry. */ static deregisterInstance(instance: SmartExit): void; /** Get all registered SmartExit instances. */ static getInstances(): SmartExit[]; /** Whether a shutdown is currently in progress. */ get isShuttingDown(): boolean; /** * Initiate orderly shutdown of all registered instances. * Safe to call multiple times — only the first call executes. */ shutdown(exitCode?: number): Promise; private handleSignal; private handleUncaughtException; /** Synchronous last-resort: SIGKILL any remaining tracked process groups. */ private handleExit; }