@ai-ecoverse/slicc-kernel 1.17.2 → 1.17.3

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.
@@ -1761,6 +1761,19 @@ function cloexecPipe2(pipe2, deps) {
1761
1761
  return r;
1762
1762
  };
1763
1763
  }
1764
+ function quietTarget(dup3, deps) {
1765
+ return (fd = -1, newfd = -1, flags = 0, ...rest) => {
1766
+ const Fs = deps.fs();
1767
+ const target = fd === newfd || flags !== 0 ? void 0 : Fs?.getStream(newfd);
1768
+ if (target && Fs?.getStream(fd)) {
1769
+ try {
1770
+ Fs.close?.(target);
1771
+ } catch {
1772
+ }
1773
+ }
1774
+ return dup3(fd, newfd, flags, ...rest);
1775
+ };
1776
+ }
1764
1777
  function cloexecByFlag(syscall, flagArg, deps) {
1765
1778
  const mark = marker(deps);
1766
1779
  return (...args) => {
@@ -1777,7 +1790,7 @@ function wrapperFactories(deps) {
1777
1790
  ...timer ? { setitimer: (f) => kernelTimer(f, timer) } : {},
1778
1791
  fcntl: (f) => cloexecFcntl(f, deps),
1779
1792
  pipe2: (f) => cloexecPipe2(f, deps),
1780
- dup3: (f) => cloexecByFlag(f, 2, deps),
1793
+ dup3: (f) => cloexecByFlag(quietTarget(f, deps), 2, deps),
1781
1794
  socket: (f) => cloexecByFlag(f, 1, deps),
1782
1795
  accept4: (f) => cloexecByFlag(f, 3, deps),
1783
1796
  ...pty ? { ioctl: (f) => ptyIoctl(f, { fs: deps.fs, heap: deps.heap, kernel: pty }) } : {}
@@ -2749,7 +2762,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
2749
2762
  };
2750
2763
  return node;
2751
2764
  };
2752
- const find = (processes2, target, own) => processes2.find((p) => own ? p.tid === target : p.pid === target || p.tid === target);
2765
+ const find = (processes2, target, own) => (own ? processes2.find((p) => p.tid === target) : void 0) ?? processes2.find((p) => p.pid === target || p.tid === target);
2753
2766
  const infoOf = (target) => find(procList().processes, target, false);
2754
2767
  const pidContent = (target, name, own = false) => () => {
2755
2768
  const listing = procList();