INNER CODE UNIT · TypeScript

pids

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

    const pids = lsofOut.trim().split(/\s+/)
      .map(s => parseInt(s, 10))
      .filter(n => Number.isInteger(n) && n > 0);

    if (pids.length === 0) return false;
    let killedAny = false;
    for (const pid of pids) {
      let image = '';
      try {
        image = execSync(`ps -p ${pid} -o comm=`, { encoding: 'utf-8', shell: '/bin/sh' }).trim();
      } catch { /* ps unavailable / pid gone — treat as unknown */ }
      if (image && !OURS.test(image)) {
        console.warn(`${e('⚠️', '[WARN]')} Port ${port} is held by "${image}" (pid ${pid}) — not a clawdcursor process; refusing to kill it. Free the port or change server.port.`);
        continue;
      }
      try {
        process.kill(pid, 'SIGKILL');
        console.log(`${e('🐾', '>')} Killed process ${pid}${image ? ` (${image})` : ''}`);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…