- Introduced a comprehensive FAQ section in the README to address common user queries regarding app installation, code handling, agent communication, and project management. - Enhanced cross-platform keyboard shortcut handling in the Electron app for better user experience on macOS and Windows/Linux. - Updated signal handling in the standalone process to ensure proper shutdown behavior across platforms. - Improved WSL user resolution logic to support default user retrieval for better compatibility. - Enhanced notification handling to support cross-platform features and improve user feedback. - Refactored SSH connection management to include additional key file types and improve authentication handling. - Updated team management services to ensure consistent process termination across platforms. - Improved project path handling in team provisioning to accommodate different operating systems. - Enhanced editor components to utilize shared utility functions for path management, improving code maintainability.
25 lines
949 B
TypeScript
25 lines
949 B
TypeScript
/**
|
|
* Check whether a process with the given PID is still alive.
|
|
*
|
|
* Cross-platform notes:
|
|
* - `process.kill(pid, 0)` sends signal 0 (a no-op probe) on all platforms.
|
|
* On Windows, Node.js internally calls `OpenProcess()` which works correctly
|
|
* for same-user processes.
|
|
* - EPERM means the process exists but we lack permission to signal it —
|
|
* still counts as alive.
|
|
* - ESRCH (Unix) or ERROR_INVALID_PARAMETER (Windows, mapped to ESRCH by
|
|
* Node.js) means the process does not exist.
|
|
* - On Windows, zombie/defunct processes are not a concern because Windows
|
|
* cleans up process handles immediately upon exit (no Unix-style zombies).
|
|
*/
|
|
export function isProcessAlive(pid: number): boolean {
|
|
try {
|
|
process.kill(pid, 0);
|
|
return true;
|
|
} catch (err: unknown) {
|
|
if (err instanceof Error && 'code' in err) {
|
|
if ((err as NodeJS.ErrnoException).code === 'EPERM') return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|