MCPcopy Create free account
hub / github.com/ProtonDriveApps/sdk / isProcessAlive

Function isProcessAlive

cli/src/events/lock.ts:65–85  ·  view source on GitHub ↗
(pid: number)

Source from the content-addressed store, hash-verified

63}
64
65function isProcessAlive(pid: number): boolean {
66 if (!Number.isInteger(pid) || pid <= 0) {
67 return false;
68 }
69 try {
70 // 0 is a signal to check if the process is alive.
71 process.kill(pid, 0);
72 return true;
73 } catch (e: unknown) {
74 const err = e as NodeJS.ErrnoException;
75 // ESRCH = no such process
76 if (err.code === 'ESRCH') {
77 return false;
78 }
79 // EPERM = operation not permitted (e.g. process is running for our perspective)
80 if (err.code === 'EPERM') {
81 return true;
82 }
83 return false;
84 }
85}
86
87/**
88 * Releases the events lock if the current process is the holder.

Callers 1

tryAcquireEventsLockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected