MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / getProcessOnPort

Function getProcessOnPort

packages/cli/src/server/portUtils.ts:191–202  ·  view source on GitHub ↗

* Get the PID of the process listening on a port (macOS/Linux only). * Returns null on Windows or if detection fails.

(port: number)

Source from the content-addressed store, hash-verified

189 * Returns null on Windows or if detection fails.
190 */
191async function getProcessOnPort(port: number): Promise<string | null> {
192 if (process.platform === "win32") return null;
193 try {
194 const { stdout } = await execFileAsync("lsof", [`-ti:${port}`, "-sTCP:LISTEN"], {
195 timeout: 2000,
196 });
197 const pid = stdout.trim().split("\n")[0]?.trim();
198 return pid || null;
199 } catch {
200 return null;
201 }
202}
203
204// ── Server discovery ───────────────────────────────────────────────────────
205

Callers 2

scanActiveServersFunction · 0.85
findPortAndServeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected