| 37 | } |
| 38 | |
| 39 | function validateCurrentRegistryEntry( |
| 40 | expectedEntry: DaemonRegistryEntry, |
| 41 | currentEntry: DaemonRegistryEntry | null, |
| 42 | socketPath: string, |
| 43 | ): void { |
| 44 | const matchesExpectedEntry = |
| 45 | currentEntry !== null && |
| 46 | currentEntry.workspaceKey === expectedEntry.workspaceKey && |
| 47 | currentEntry.socketPath === expectedEntry.socketPath && |
| 48 | currentEntry.pid === expectedEntry.pid && |
| 49 | currentEntry.instanceId === expectedEntry.instanceId; |
| 50 | |
| 51 | if (!matchesExpectedEntry) { |
| 52 | throw new Error(`Cannot force-stop daemon at ${socketPath}: daemon registry metadata changed`); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | function signalDaemonPid(pid: number, signal: NodeJS.Signals): boolean { |
| 57 | try { |