#!/usr/bin/env node

// src/common/process-probe.ts
function getErrnoCode(err) {
  if (err && typeof err === "object" && "code" in err) {
    const code = err.code;
    return typeof code === "string" ? code : void 0;
  }
  return void 0;
}
function getErrorMessage(err) {
  return err instanceof Error ? err.message : String(err);
}
function probeProcess(pid) {
  try {
    process.kill(pid, 0);
    return { status: "alive" };
  } catch (err) {
    const code = getErrnoCode(err);
    const message = getErrorMessage(err);
    if (code === "ESRCH") return { status: "not-found", code, message };
    if (code === "EPERM") return { status: "permission-denied", code, message };
    return { status: "unknown", code, message };
  }
}
function processExistsOrIsInaccessible(pid) {
  const probe = probeProcess(pid);
  return probe.status === "alive" || probe.status === "permission-denied";
}

// src/common/safe-unlink.ts
import { unlinkSync } from "fs";
function unlinkIfPresent(path, unlink = unlinkSync) {
  try {
    unlink(path);
  } catch (err) {
    if (err.code === "ENOENT") return;
    throw err;
  }
}

export {
  getErrnoCode,
  getErrorMessage,
  probeProcess,
  processExistsOrIsInaccessible,
  unlinkIfPresent
};
//# sourceMappingURL=chunk-7R3UDY6R.js.map