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

Function acquireProcessLifetimeLock

src/utils/nativeInstaller/pidLock.ts:299–324  ·  view source on GitHub ↗
(
  versionPath: string,
  lockFilePath: string,
)

Source from the content-addressed store, hash-verified

297 * This is used for locking the currently running version
298 */
299export async function acquireProcessLifetimeLock(
300 versionPath: string,
301 lockFilePath: string,
302): Promise<boolean> {
303 const release = await tryAcquireLock(versionPath, lockFilePath)
304
305 if (!release) {
306 return false
307 }
308
309 // Register cleanup on process exit
310 const cleanup = () => {
311 try {
312 release()
313 } catch {
314 // Ignore errors during process exit
315 }
316 }
317
318 process.on('exit', cleanup)
319 process.on('SIGINT', cleanup)
320 process.on('SIGTERM', cleanup)
321
322 // Don't call release() - we want to hold the lock until process exits
323 return true
324}
325
326/**
327 * Execute a callback while holding a lock

Callers 1

lockCurrentVersionFunction · 0.85

Calls 2

tryAcquireLockFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected