(sessionId: string)
| 222 | } |
| 223 | |
| 224 | export function isProcessRunning(sessionId: string): boolean { |
| 225 | // Primary source: PtyManager in-memory state for agents spawned under this |
| 226 | // daemon. Falls back to PID-probe for legacy session records that may have |
| 227 | // been started before the PTY refactor. |
| 228 | if (ptyManager.isRunning(sessionId)) return true; |
| 229 | |
| 230 | const session = getSession(sessionId); |
| 231 | if (!session?.pid) return false; |
| 232 | try { |
| 233 | process.kill(session.pid, 0); |
| 234 | return true; |
| 235 | } catch { |
| 236 | return false; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | export function stopProcess(sessionId: string): boolean { |
| 241 | if (ptyManager.isRunning(sessionId)) { |
no test coverage detected