mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
refactor: extract process management utilities for cross-platform support
Consolidate process lifecycle management (kill, check alive) into a new utility module with proper Windows/Unix handling, replacing scattered process.kill() calls with consistent async APIs.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
import { logger } from '@/ui/logger';
|
||||
import { restoreTerminalState } from '@/ui/terminalState';
|
||||
import { killProcessByChildProcess } from '@/utils/process';
|
||||
|
||||
/**
|
||||
* Filter out 'resume' subcommand which is managed internally by hapi.
|
||||
@@ -76,7 +77,7 @@ export async function codexLocal(opts: {
|
||||
if (child.exitCode === null && !child.killed) {
|
||||
logger.debug('[CodexLocal] Abort timeout reached, sending SIGKILL');
|
||||
try {
|
||||
child.kill('SIGKILL');
|
||||
void killProcessByChildProcess(child, true);
|
||||
} catch (error) {
|
||||
logger.debug('[CodexLocal] Failed to send SIGKILL:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user