botmux-workflow-core 3.43.0 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1524,6 +1524,19 @@ var import_node_path = require("node:path");
1524
1524
  // src/utils/process-identity.ts
1525
1525
  var import_node_child_process = require("node:child_process");
1526
1526
  var import_node_fs2 = require("node:fs");
1527
+
1528
+ // src/utils/proc-stat.ts
1529
+ var PROC_STAT_STARTTIME_INDEX = 19;
1530
+ function procStatFieldsAfterComm(raw) {
1531
+ const closeParen = raw.lastIndexOf(")");
1532
+ if (closeParen < 0) return void 0;
1533
+ return raw.slice(closeParen + 2).trim().split(/\s+/);
1534
+ }
1535
+ function procStatStartTime(raw) {
1536
+ return procStatFieldsAfterComm(raw)?.[PROC_STAT_STARTTIME_INDEX] || void 0;
1537
+ }
1538
+
1539
+ // src/utils/process-identity.ts
1527
1540
  var LINUX_BOOT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1528
1541
  function readLinuxBootIdentity() {
1529
1542
  if (process.platform !== "linux") return void 0;
@@ -1538,15 +1551,10 @@ function readLinuxBootIdentity() {
1538
1551
  }
1539
1552
  }
1540
1553
  function readProcessStartIdentity(pid) {
1541
- if (!Number.isInteger(pid) || pid <= 1) return void 0;
1554
+ if (!Number.isSafeInteger(pid) || pid <= 1) return void 0;
1542
1555
  if (process.platform === "linux") {
1543
1556
  try {
1544
- const raw = (0, import_node_fs2.readFileSync)(`/proc/${pid}/stat`, "utf8");
1545
- const closeParen = raw.lastIndexOf(")");
1546
- if (closeParen >= 0) {
1547
- const fields = raw.slice(closeParen + 2).trim().split(/\s+/);
1548
- if (fields[19]) return fields[19];
1549
- }
1557
+ return procStatStartTime((0, import_node_fs2.readFileSync)(`/proc/${pid}/stat`, "utf8"));
1550
1558
  } catch {
1551
1559
  }
1552
1560
  return void 0;
@@ -1652,6 +1660,19 @@ var logger = {
1652
1660
  }
1653
1661
  };
1654
1662
 
1663
+ // src/utils/process-alive.ts
1664
+ function probeErrno(pid) {
1665
+ try {
1666
+ process.kill(pid, 0);
1667
+ return null;
1668
+ } catch (err) {
1669
+ return err?.code;
1670
+ }
1671
+ }
1672
+ function pidIsSignalable(pid) {
1673
+ return probeErrno(pid) === null;
1674
+ }
1675
+
1655
1676
  // src/utils/file-lock.ts
1656
1677
  var MAX_WAIT_MS = 5e3;
1657
1678
  var RETRY_BASE_MS = 25;
@@ -1717,12 +1738,7 @@ function isHolderAliveSync(holder) {
1717
1738
  const pid = holder.pid;
1718
1739
  if (!pid) return false;
1719
1740
  if (pid === process.pid) return true;
1720
- try {
1721
- process.kill(pid, 0);
1722
- return true;
1723
- } catch {
1724
- return false;
1725
- }
1741
+ return pidIsSignalable(pid);
1726
1742
  }
1727
1743
  function sleepSync(ms) {
1728
1744
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);