MCPcopy Index your code
hub / github.com/codeaashu/claude-code / checkComputerUseLock

Function checkComputerUseLock

src/utils/computerUse/computerUseLock.ts:110–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108 * `request_access`. Does NOT create — that's `tryAcquireComputerUseLock`'s job.
109 */
110export async function checkComputerUseLock(): Promise<CheckResult> {
111 const existing = await readLock()
112 if (!existing) return { kind: 'free' }
113 if (existing.sessionId === getSessionId()) return { kind: 'held_by_self' }
114 if (isProcessRunning(existing.pid)) {
115 return { kind: 'blocked', by: existing.sessionId }
116 }
117 logForDebugging(
118 `Recovering stale computer-use lock from session ${existing.sessionId} (PID ${existing.pid})`,
119 )
120 await unlink(getLockPath()).catch(() => {})
121 return { kind: 'free' }
122}
123
124/**
125 * Zero-syscall check: does THIS process believe it holds the lock?

Callers 1

buildSessionContextFunction · 0.85

Calls 6

getSessionIdFunction · 0.85
logForDebuggingFunction · 0.85
unlinkFunction · 0.85
readLockFunction · 0.70
isProcessRunningFunction · 0.70
getLockPathFunction · 0.70

Tested by

no test coverage detected