INNER CODE UNIT · TypeScript

forceKillPort

AmrDab/clawdcursor · src/surface/cli.ts:130

async function forceKillPort(port: number): Promise<boolean> {
  const { execSync } = await import('child_process');
  const os = await import('os');

  // #114: only ever kill processes that are plausibly OURS. The port is
  // configurable and ports get reused — blindly SIGKILLing whatever listens on
  // it can take down an unrelated app (dev server, another tool). clawdcursor
  // always runs under node, so a listener with any other image name is not
  // ours: skip it, tell the user, and let them resolve the conflict.
  const OURS = /node|clawdcursor/i;

  if (os.platform() === 'win32') {
    try {
      const output = execSync(
        `netstat -ano | findstr :${port} | findstr LISTENING`,
        { encoding: 'utf-8' },
      );
      const pids = new Set(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…