botmux-workflow-core 3.42.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.
@@ -1519,6 +1519,19 @@ import { basename, dirname, join } from "node:path";
1519
1519
  // src/utils/process-identity.ts
1520
1520
  import { execFileSync } from "node:child_process";
1521
1521
  import { existsSync, readFileSync } from "node:fs";
1522
+
1523
+ // src/utils/proc-stat.ts
1524
+ var PROC_STAT_STARTTIME_INDEX = 19;
1525
+ function procStatFieldsAfterComm(raw) {
1526
+ const closeParen = raw.lastIndexOf(")");
1527
+ if (closeParen < 0) return void 0;
1528
+ return raw.slice(closeParen + 2).trim().split(/\s+/);
1529
+ }
1530
+ function procStatStartTime(raw) {
1531
+ return procStatFieldsAfterComm(raw)?.[PROC_STAT_STARTTIME_INDEX] || void 0;
1532
+ }
1533
+
1534
+ // src/utils/process-identity.ts
1522
1535
  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;
1523
1536
  function readLinuxBootIdentity() {
1524
1537
  if (process.platform !== "linux") return void 0;
@@ -1533,15 +1546,10 @@ function readLinuxBootIdentity() {
1533
1546
  }
1534
1547
  }
1535
1548
  function readProcessStartIdentity(pid) {
1536
- if (!Number.isInteger(pid) || pid <= 1) return void 0;
1549
+ if (!Number.isSafeInteger(pid) || pid <= 1) return void 0;
1537
1550
  if (process.platform === "linux") {
1538
1551
  try {
1539
- const raw = readFileSync(`/proc/${pid}/stat`, "utf8");
1540
- const closeParen = raw.lastIndexOf(")");
1541
- if (closeParen >= 0) {
1542
- const fields = raw.slice(closeParen + 2).trim().split(/\s+/);
1543
- if (fields[19]) return fields[19];
1544
- }
1552
+ return procStatStartTime(readFileSync(`/proc/${pid}/stat`, "utf8"));
1545
1553
  } catch {
1546
1554
  }
1547
1555
  return void 0;
@@ -1647,6 +1655,19 @@ var logger = {
1647
1655
  }
1648
1656
  };
1649
1657
 
1658
+ // src/utils/process-alive.ts
1659
+ function probeErrno(pid) {
1660
+ try {
1661
+ process.kill(pid, 0);
1662
+ return null;
1663
+ } catch (err) {
1664
+ return err?.code;
1665
+ }
1666
+ }
1667
+ function pidIsSignalable(pid) {
1668
+ return probeErrno(pid) === null;
1669
+ }
1670
+
1650
1671
  // src/utils/file-lock.ts
1651
1672
  var MAX_WAIT_MS = 5e3;
1652
1673
  var RETRY_BASE_MS = 25;
@@ -1712,12 +1733,7 @@ function isHolderAliveSync(holder) {
1712
1733
  const pid = holder.pid;
1713
1734
  if (!pid) return false;
1714
1735
  if (pid === process.pid) return true;
1715
- try {
1716
- process.kill(pid, 0);
1717
- return true;
1718
- } catch {
1719
- return false;
1720
- }
1736
+ return pidIsSignalable(pid);
1721
1737
  }
1722
1738
  function sleepSync(ms) {
1723
1739
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);