MCPcopy Index your code
hub / github.com/callstack/agent-device / readProcessLockDiagnostics

Function readProcessLockDiagnostics

src/utils/process-lock.ts:103–123  ·  view source on GitHub ↗
(
  lockDirPath: string,
  ownerFilePath: string,
)

Source from the content-addressed store, hash-verified

101}
102
103function readProcessLockDiagnostics(
104 lockDirPath: string,
105 ownerFilePath: string,
106): Record<string, unknown> {
107 const nowMs = Date.now();
108 const owner = readProcessLockOwner(ownerFilePath);
109 let lockAgeMs: number | undefined;
110 try {
111 lockAgeMs = Math.max(0, Math.round(nowMs - fs.statSync(lockDirPath).mtimeMs));
112 } catch {}
113 return {
114 ...(lockAgeMs !== undefined ? { lockAgeMs } : {}),
115 ...(owner
116 ? {
117 ownerPid: owner.pid,
118 ownerStartTime: owner.startTime,
119 ownerAgeMs: Math.max(0, Math.round(nowMs - owner.acquiredAtMs)),
120 }
121 : {}),
122 };
123}
124
125function isLiveProcessLockOwner(owner: ProcessLockOwner): boolean {
126 if (!Number.isInteger(owner.pid) || owner.pid <= 0) {

Callers 1

acquireProcessLockFunction · 0.85

Calls 1

readProcessLockOwnerFunction · 0.85

Tested by

no test coverage detected