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

Function tryCreateExclusive

src/utils/computerUse/computerUseLock.ts:79–87  ·  view source on GitHub ↗

* Attempt to create the lock file atomically with O_EXCL. * Returns true on success, false if the file already exists. * Throws for other errors.

(lock: ComputerUseLock)

Source from the content-addressed store, hash-verified

77 * Throws for other errors.
78 */
79async function tryCreateExclusive(lock: ComputerUseLock): Promise<boolean> {
80 try {
81 await writeFile(getLockPath(), jsonStringify(lock), { flag: 'wx' })
82 return true
83 } catch (e: unknown) {
84 if (getErrnoCode(e) === 'EEXIST') return false
85 throw e
86 }
87}
88
89/**
90 * Register a shutdown cleanup handler so the lock is released even if

Callers 1

Calls 3

jsonStringifyFunction · 0.85
getErrnoCodeFunction · 0.85
getLockPathFunction · 0.70

Tested by

no test coverage detected