MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / acquireLockViaExclusiveOpen

Function acquireLockViaExclusiveOpen

src/mcp/daemon.ts:585–599  ·  view source on GitHub ↗
(pidPath: string, info: DaemonLockInfo)

Source from the content-addressed store, hash-verified

583 * window between create and write. Exported for testing.
584 */
585export function acquireLockViaExclusiveOpen(pidPath: string, info: DaemonLockInfo): boolean {
586 let fd: number;
587 try {
588 fd = fs.openSync(pidPath, 'wx', 0o600); // O_CREAT | O_EXCL | O_WRONLY
589 } catch (err: unknown) {
590 if ((err as NodeJS.ErrnoException).code === 'EEXIST') return false;
591 throw err;
592 }
593 try {
594 fs.writeSync(fd, encodeLockInfo(info));
595 } finally {
596 fs.closeSync(fd);
597 }
598 return true;
599}
600
601/**
602 * Remove a stale pidfile, but only if it still names a dead process. Re-reads

Callers 2

tryAcquireDaemonLockFunction · 0.85

Calls 2

encodeLockInfoFunction · 0.90
openSyncMethod · 0.80

Tested by

no test coverage detected