@ai-ecoverse/slicc-kernel 1.107.0 → 1.108.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.
@@ -2491,7 +2491,7 @@ var KERNEL_VERSION, OS_RELEASE;
2491
2491
  var init_version = __esm({
2492
2492
  "src/version.ts"() {
2493
2493
  "use strict";
2494
- KERNEL_VERSION = true ? "1.107.0" : "0.0.0-dev";
2494
+ KERNEL_VERSION = true ? "1.108.0" : "0.0.0-dev";
2495
2495
  OS_RELEASE = "6.0.0-slicc";
2496
2496
  }
2497
2497
  });
@@ -4721,7 +4721,7 @@ var init_process_signals = __esm({
4721
4721
  init_signals();
4722
4722
  init_sync_sab_wire();
4723
4723
  SignalGate = class {
4724
- reported = { caught: 0, ignored: 0 };
4724
+ reported = { caught: 0, ignored: 0, nocldwait: false };
4725
4725
  restart = 0;
4726
4726
  lastDelivered = 0;
4727
4727
  depth = 0;
@@ -4774,10 +4774,18 @@ var init_process_signals = __esm({
4774
4774
  if (!masks) return;
4775
4775
  this.restart = masks.restart;
4776
4776
  const { caught, ignored, defaults = 0 } = masks;
4777
- const same = caught === this.reported.caught && ignored === this.reported.ignored;
4777
+ const nocldwait = masks.nocldwait === true;
4778
+ const was = this.reported;
4779
+ const same = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
4778
4780
  if (same && defaults === 0) return;
4779
- this.reported = { caught, ignored };
4780
- const req = { op: "sig-mask", caught, ignored, ...defaults ? { defaults } : {} };
4781
+ this.reported = { caught, ignored, nocldwait };
4782
+ const req = {
4783
+ op: "sig-mask",
4784
+ caught,
4785
+ ignored,
4786
+ ...defaults ? { defaults } : {},
4787
+ ...nocldwait ? { nocldwait } : {}
4788
+ };
4781
4789
  this.raw.call(req, Number.POSITIVE_INFINITY, "sig-mask");
4782
4790
  }
4783
4791
  quiet(fn) {
@@ -6395,7 +6403,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6395
6403
  symlink: (target, link) => mutating(() => bridge.symlink(target, link), ...entry(link)),
6396
6404
  chmod: (p, mode) => rewriting(p, () => bridge.chmod(p, mode)),
6397
6405
  utimes: (p, a, m, now2) => rewriting(p, () => bridge.utimes(p, a, m, now2)),
6398
- lutimes: (p, a, m, now2) => mutating(() => bridge.lutimes(p, a, m, now2), p),
6406
+ lutimes: (p, a, m, now2) => mutating(() => bridge.lutimes(p, a, m, now2)),
6399
6407
  ...bridge.hold ? { hold: bridge.hold.bind(bridge) } : {},
6400
6408
  ...bridge.access ? { access: bridge.access.bind(bridge) } : {},
6401
6409
  ...bridge.kept ? { kept: bridge.kept.bind(bridge) } : {},
@@ -6436,7 +6444,7 @@ function pinnedIo2(bridge, handle, rewriting) {
6436
6444
  } : {}
6437
6445
  };
6438
6446
  }
6439
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, SHARED_IDS_BYTES, StatCache;
6447
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, SHARED_IDS_BYTES, StatCache;
6440
6448
  var init_wasi_files = __esm({
6441
6449
  "src/process/wasi/wasi-files.ts"() {
6442
6450
  "use strict";
@@ -6657,6 +6665,7 @@ var init_wasi_files = __esm({
6657
6665
  };
6658
6666
  MAX_LINKS = 40;
6659
6667
  MISS_TTL_MS = 20;
6668
+ CACHE_CAP = 8192;
6660
6669
  FS_GEN = 4;
6661
6670
  CRED_GEN = 5;
6662
6671
  RING2 = 8;
@@ -6668,6 +6677,7 @@ var init_wasi_files = __esm({
6668
6677
  lstats = /* @__PURE__ */ new Map();
6669
6678
  byHash = /* @__PURE__ */ new Map();
6670
6679
  byIno = /* @__PURE__ */ new Map();
6680
+ missed = /* @__PURE__ */ new Map();
6671
6681
  shared;
6672
6682
  seen;
6673
6683
  constructor(shared) {
@@ -6675,7 +6685,14 @@ var init_wasi_files = __esm({
6675
6685
  this.seen = shared ? Atomics.load(shared, FS_GEN) : 0;
6676
6686
  }
6677
6687
  put(map, path, entry) {
6688
+ if (this.stats.size + this.lstats.size + this.byHash.size + this.byIno.size >= CACHE_CAP)
6689
+ this.clear();
6678
6690
  map.set(path, entry);
6691
+ if ("until" in entry) {
6692
+ const paths = this.missed.get(map) ?? /* @__PURE__ */ new Set();
6693
+ paths.add(path);
6694
+ this.missed.set(map, paths);
6695
+ }
6679
6696
  if (!this.shared) return;
6680
6697
  index(this.byHash, pathHash(path), path);
6681
6698
  const ino = inoKey(entry);
@@ -6702,12 +6719,21 @@ var init_wasi_files = __esm({
6702
6719
  this.lstats.delete(path);
6703
6720
  }
6704
6721
  mutated(paths, ino = 0) {
6705
- this.clear();
6706
- if (!this.shared) return;
6707
6722
  const key = ino % 4294967296 | 0;
6723
+ if (paths.length === 0 || !this.shared) this.clear();
6724
+ if (!this.shared) return;
6708
6725
  for (const [i, hash] of (paths.length > 0 ? paths.map(pathHash) : [0]).entries()) {
6709
- this.seen = this.publish(this.shared, hash, i === 0 ? key : 0);
6726
+ const g = this.publish(this.shared, hash, i === 0 ? key : 0);
6727
+ if (paths.length > 0) this.replay(g - 1);
6728
+ this.seen = g;
6710
6729
  }
6730
+ if (paths.length === 0) return;
6731
+ for (const [i, path] of paths.entries()) {
6732
+ this.stats.delete(path);
6733
+ this.lstats.delete(path);
6734
+ this.drop(pathHash(path), i === 0 ? key : 0);
6735
+ }
6736
+ this.forgetMisses();
6711
6737
  }
6712
6738
  inoOf(path, look) {
6713
6739
  if (!this.shared) return 0;
@@ -6755,7 +6781,14 @@ var init_wasi_files = __esm({
6755
6781
  this.byHash.delete(hash);
6756
6782
  if (ino !== 0) this.byIno.delete(ino);
6757
6783
  }
6784
+ forgetMisses() {
6785
+ for (const [map, paths] of this.missed) {
6786
+ for (const path of paths) if ("until" in (map.get(path) ?? {})) map.delete(path);
6787
+ }
6788
+ this.missed.clear();
6789
+ }
6758
6790
  clear() {
6791
+ this.missed.clear();
6759
6792
  this.stats.clear();
6760
6793
  this.lstats.clear();
6761
6794
  this.byHash.clear();
@@ -7934,6 +7967,136 @@ var init_wasi_poll = __esm({
7934
7967
  }
7935
7968
  });
7936
7969
 
7970
+ // src/process/wasi/wasi-sigmask.ts
7971
+ var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER, NS_PER_MS2, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
7972
+ var init_wasi_sigmask = __esm({
7973
+ "src/process/wasi/wasi-sigmask.ts"() {
7974
+ "use strict";
7975
+ init_signals();
7976
+ init_sync_sab_wire();
7977
+ init_wasi_abi();
7978
+ UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
7979
+ LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
7980
+ FOREVER = 0xffffffffffffffffn;
7981
+ NS_PER_MS2 = 1000000n;
7982
+ POLL_MS = 50;
7983
+ SIG_BLOCK = 0;
7984
+ SIG_UNBLOCK = 1;
7985
+ SIG_SETMASK = 2;
7986
+ kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
7987
+ libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
7988
+ apply = (how, mask, set) => {
7989
+ if (how === SIG_BLOCK) return mask | set;
7990
+ if (how === SIG_UNBLOCK) return mask & ~set;
7991
+ return set;
7992
+ };
7993
+ WasiSigmask = class {
7994
+ lo;
7995
+ hi;
7996
+ header;
7997
+ deliver;
7998
+ process;
7999
+ tid;
8000
+ constructor(header, deliver, process, tid = 1) {
8001
+ this.header = header;
8002
+ this.deliver = deliver;
8003
+ this.process = process;
8004
+ this.tid = tid;
8005
+ this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
8006
+ this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
8007
+ }
8008
+ static unsupported(header) {
8009
+ storeBlocked(header, [0, 0]);
8010
+ }
8011
+ set(how, setLo, setHi, old) {
8012
+ if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
8013
+ old(this.lo >>> 0, this.hi >>> 0);
8014
+ this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
8015
+ this.hi = apply(how, this.hi, setHi | 0);
8016
+ const now = kernelBits(this.lo);
8017
+ storeBlocked(this.header, [now, this.hi]);
8018
+ if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
8019
+ return E.SUCCESS;
8020
+ }
8021
+ swap(setLo, setHi) {
8022
+ const old = [this.lo, this.hi];
8023
+ this.lo = setLo & ~LIBC_UNBLOCKABLE;
8024
+ this.hi = setHi | 0;
8025
+ storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
8026
+ return old;
8027
+ }
8028
+ deliverUnblocked() {
8029
+ const now = Atomics.load(this.header, SAB_I_BLOCKED);
8030
+ if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
8031
+ this.deliver();
8032
+ return true;
8033
+ }
8034
+ restore([lo, hi]) {
8035
+ this.set(SIG_SETMASK, lo, hi, () => {
8036
+ });
8037
+ }
8038
+ blockedBits() {
8039
+ return Atomics.load(this.header, SAB_I_BLOCKED);
8040
+ }
8041
+ blocks(sig) {
8042
+ return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
8043
+ }
8044
+ inherited() {
8045
+ return [kernelBits(this.lo), this.hi];
8046
+ }
8047
+ discard(sig) {
8048
+ Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
8049
+ if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
8050
+ }
8051
+ sigwait(setLo, timeoutNs, publish, took, entered = false) {
8052
+ const set = kernelBits(setLo | 0);
8053
+ const value2 = BigInt.asUintN(64, timeoutNs);
8054
+ const deadline = value2 === FOREVER ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS2 - 1n) / NS_PER_MS2);
8055
+ publish(set);
8056
+ try {
8057
+ for (; ; ) {
8058
+ const seen = Atomics.load(this.header, SAB_I_SIGNALS);
8059
+ const sig = this.take(set);
8060
+ if (sig !== 0) {
8061
+ took(sig);
8062
+ return E.SUCCESS;
8063
+ }
8064
+ if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
8065
+ const left = deadline - performance.now();
8066
+ if (left <= 0) return E.AGAIN;
8067
+ Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
8068
+ }
8069
+ } finally {
8070
+ publish(0);
8071
+ }
8072
+ }
8073
+ take(set) {
8074
+ for (const header of this.process ? [this.header, this.process] : [this.header]) {
8075
+ const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
8076
+ if (ready === 0) continue;
8077
+ const bit = ready & -ready;
8078
+ if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
8079
+ }
8080
+ return 0;
8081
+ }
8082
+ interrupted() {
8083
+ const killed = this.process ?? this.header;
8084
+ if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
8085
+ this.deliver();
8086
+ return true;
8087
+ }
8088
+ if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
8089
+ while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
8090
+ return true;
8091
+ }
8092
+ pending() {
8093
+ const own = Atomics.load(this.header, SAB_I_SIGNALS);
8094
+ return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
8095
+ }
8096
+ };
8097
+ }
8098
+ });
8099
+
7937
8100
  // src/process/wasi/wasi-termios.ts
7938
8101
  function writeTermios(mem, ptr, termios) {
7939
8102
  mem.bytes(ptr, OSPEED + 4).fill(0);
@@ -8012,8 +8175,8 @@ var init_wasi_termios = __esm({
8012
8175
  // src/process/wasi/wasix-epoll.ts
8013
8176
  function timeoutMs(ns) {
8014
8177
  const value2 = BigInt.asUintN(64, ns);
8015
- if (value2 === FOREVER) return -1;
8016
- const ms = (value2 + NS_PER_MS2 - 1n) / NS_PER_MS2;
8178
+ if (value2 === FOREVER2) return -1;
8179
+ const ms = (value2 + NS_PER_MS3 - 1n) / NS_PER_MS3;
8017
8180
  return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
8018
8181
  }
8019
8182
  function wasixEpollImports(host) {
@@ -8074,7 +8237,7 @@ function wasixEpollImports(host) {
8074
8237
  }
8075
8238
  };
8076
8239
  }
8077
- var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER, MAX_TIMEOUT_MS, NS_PER_MS2, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, WASIX_OPS, DUAL_OPS;
8240
+ var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER2, MAX_TIMEOUT_MS, NS_PER_MS3, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, WASIX_OPS, DUAL_OPS;
8078
8241
  var init_wasix_epoll = __esm({
8079
8242
  "src/process/wasi/wasix-epoll.ts"() {
8080
8243
  "use strict";
@@ -8084,9 +8247,9 @@ var init_wasix_epoll = __esm({
8084
8247
  DATA_OFFSET = 8;
8085
8248
  DATA_SIZE = 24;
8086
8249
  MAX_EVENTS = 4096;
8087
- FOREVER = 0xffffffffffffffffn;
8250
+ FOREVER2 = 0xffffffffffffffffn;
8088
8251
  MAX_TIMEOUT_MS = 2147483647;
8089
- NS_PER_MS2 = 1000000n;
8252
+ NS_PER_MS3 = 1000000n;
8090
8253
  EVENTFD_SEMAPHORE = 1;
8091
8254
  EVENTFD_NONBLOCK = 4;
8092
8255
  EVENTFD_MAX = 0xfffffffffffffffen;
@@ -8481,7 +8644,7 @@ function filestatOf(path, s) {
8481
8644
  size: BigInt(s.size),
8482
8645
  ino: s.ino !== void 0 ? BigInt(s.ino) : pathInode(path),
8483
8646
  ...s.nlink !== void 0 ? { nlink: BigInt(s.nlink) } : {},
8484
- mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS3
8647
+ mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS4
8485
8648
  };
8486
8649
  }
8487
8650
  function kernelFiletype(kind) {
@@ -8531,7 +8694,7 @@ function wrap(table) {
8531
8694
  }
8532
8695
  return out;
8533
8696
  }
8534
- var WasiExit, IDS, NS_PER_MS3, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
8697
+ var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
8535
8698
  var init_wasi_host = __esm({
8536
8699
  "src/process/wasi/wasi-host.ts"() {
8537
8700
  "use strict";
@@ -8548,6 +8711,7 @@ var init_wasi_host = __esm({
8548
8711
  init_wasi_files();
8549
8712
  init_wasi_memory();
8550
8713
  init_wasi_poll();
8714
+ init_wasi_sigmask();
8551
8715
  init_wasi_termios();
8552
8716
  init_wasix_epoll();
8553
8717
  init_wasix_sockets();
@@ -8559,14 +8723,14 @@ var init_wasi_host = __esm({
8559
8723
  }
8560
8724
  };
8561
8725
  IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
8562
- NS_PER_MS3 = 1000000n;
8726
+ NS_PER_MS4 = 1000000n;
8563
8727
  AT_SYMLINK_NOFOLLOW2 = 1;
8564
8728
  AT_EACCESS2 = 2;
8565
8729
  ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
8566
8730
  GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
8567
8731
  S_IFIFO = 4096;
8568
8732
  DEFAULT_UMASK = 18;
8569
- MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS3;
8733
+ MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
8570
8734
  MAX_READ = 1024 * 1024;
8571
8735
  SIGPIPE_EXIT = 128 + SIG.PIPE;
8572
8736
  SIG_IGN = 1;
@@ -8843,6 +9007,11 @@ var init_wasi_host = __esm({
8843
9007
  this.entered
8844
9008
  );
8845
9009
  },
9010
+ sigaction_inherited: (out) => {
9011
+ const bits = this.o.kernel.call({ op: "sig-inherited" });
9012
+ mem.view().setBigUint64(out, BigInt(libcBits(bits) >>> 0), true);
9013
+ return E.SUCCESS;
9014
+ },
8846
9015
  sigpending_get: (out) => {
8847
9016
  if (!this.sigmask) return E.NOSYS;
8848
9017
  mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
@@ -8922,7 +9091,7 @@ var init_wasi_host = __esm({
8922
9091
  return this.cache;
8923
9092
  }
8924
9093
  now(id) {
8925
- if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS3;
9094
+ if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS4;
8926
9095
  if (id === CLOCK.MONOTONIC) {
8927
9096
  return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
8928
9097
  }
@@ -9463,7 +9632,7 @@ var init_wasi_host = __esm({
9463
9632
  current ??= statOf(path);
9464
9633
  return current[field2] ?? current.mtimeMs ?? now;
9465
9634
  };
9466
- const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS3) : kept(field2);
9635
+ const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS4) : kept(field2);
9467
9636
  (follow2 ? this.o.fs.utimes : this.o.fs.lutimes).call(
9468
9637
  this.o.fs,
9469
9638
  path,
@@ -10463,138 +10632,8 @@ var init_wasi_procfs = __esm({
10463
10632
  }
10464
10633
  });
10465
10634
 
10466
- // src/process/wasi/wasi-sigmask.ts
10467
- var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER2, NS_PER_MS4, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
10468
- var init_wasi_sigmask = __esm({
10469
- "src/process/wasi/wasi-sigmask.ts"() {
10470
- "use strict";
10471
- init_signals();
10472
- init_sync_sab_wire();
10473
- init_wasi_abi();
10474
- UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
10475
- LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
10476
- FOREVER2 = 0xffffffffffffffffn;
10477
- NS_PER_MS4 = 1000000n;
10478
- POLL_MS = 50;
10479
- SIG_BLOCK = 0;
10480
- SIG_UNBLOCK = 1;
10481
- SIG_SETMASK = 2;
10482
- kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
10483
- libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
10484
- apply = (how, mask, set) => {
10485
- if (how === SIG_BLOCK) return mask | set;
10486
- if (how === SIG_UNBLOCK) return mask & ~set;
10487
- return set;
10488
- };
10489
- WasiSigmask = class {
10490
- lo;
10491
- hi;
10492
- header;
10493
- deliver;
10494
- process;
10495
- tid;
10496
- constructor(header, deliver, process, tid = 1) {
10497
- this.header = header;
10498
- this.deliver = deliver;
10499
- this.process = process;
10500
- this.tid = tid;
10501
- this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
10502
- this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
10503
- }
10504
- static unsupported(header) {
10505
- storeBlocked(header, [0, 0]);
10506
- }
10507
- set(how, setLo, setHi, old) {
10508
- if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
10509
- old(this.lo >>> 0, this.hi >>> 0);
10510
- this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
10511
- this.hi = apply(how, this.hi, setHi | 0);
10512
- const now = kernelBits(this.lo);
10513
- storeBlocked(this.header, [now, this.hi]);
10514
- if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
10515
- return E.SUCCESS;
10516
- }
10517
- swap(setLo, setHi) {
10518
- const old = [this.lo, this.hi];
10519
- this.lo = setLo & ~LIBC_UNBLOCKABLE;
10520
- this.hi = setHi | 0;
10521
- storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
10522
- return old;
10523
- }
10524
- deliverUnblocked() {
10525
- const now = Atomics.load(this.header, SAB_I_BLOCKED);
10526
- if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
10527
- this.deliver();
10528
- return true;
10529
- }
10530
- restore([lo, hi]) {
10531
- this.set(SIG_SETMASK, lo, hi, () => {
10532
- });
10533
- }
10534
- blockedBits() {
10535
- return Atomics.load(this.header, SAB_I_BLOCKED);
10536
- }
10537
- blocks(sig) {
10538
- return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
10539
- }
10540
- inherited() {
10541
- return [kernelBits(this.lo), this.hi];
10542
- }
10543
- discard(sig) {
10544
- Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
10545
- if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
10546
- }
10547
- sigwait(setLo, timeoutNs, publish, took, entered = false) {
10548
- const set = kernelBits(setLo | 0);
10549
- const value2 = BigInt.asUintN(64, timeoutNs);
10550
- const deadline = value2 === FOREVER2 ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS4 - 1n) / NS_PER_MS4);
10551
- publish(set);
10552
- try {
10553
- for (; ; ) {
10554
- const seen = Atomics.load(this.header, SAB_I_SIGNALS);
10555
- const sig = this.take(set);
10556
- if (sig !== 0) {
10557
- took(sig);
10558
- return E.SUCCESS;
10559
- }
10560
- if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
10561
- const left = deadline - performance.now();
10562
- if (left <= 0) return E.AGAIN;
10563
- Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
10564
- }
10565
- } finally {
10566
- publish(0);
10567
- }
10568
- }
10569
- take(set) {
10570
- for (const header of this.process ? [this.header, this.process] : [this.header]) {
10571
- const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
10572
- if (ready === 0) continue;
10573
- const bit = ready & -ready;
10574
- if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
10575
- }
10576
- return 0;
10577
- }
10578
- interrupted() {
10579
- const killed = this.process ?? this.header;
10580
- if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
10581
- this.deliver();
10582
- return true;
10583
- }
10584
- if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
10585
- while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
10586
- return true;
10587
- }
10588
- pending() {
10589
- const own = Atomics.load(this.header, SAB_I_SIGNALS);
10590
- return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
10591
- }
10592
- };
10593
- }
10594
- });
10595
-
10596
10635
  // src/process/wasi/wasi-signals.ts
10597
- var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
10636
+ var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, SA_NOCLDWAIT, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
10598
10637
  var init_wasi_signals = __esm({
10599
10638
  "src/process/wasi/wasi-signals.ts"() {
10600
10639
  "use strict";
@@ -10605,6 +10644,7 @@ var init_wasi_signals = __esm({
10605
10644
  KERNEL_DEFAULTS = [SIG.TSTP, SIG.TTIN, SIG.TTOU, SIG.CHLD, SIG.CONT, SIG.URG, SIG.WINCH].map(sigbit).reduce((m, bit) => m | bit, 0);
10606
10645
  LIBC_DEFAULT_EXIT = 127;
10607
10646
  SA_RESTART = 268435456;
10647
+ SA_NOCLDWAIT = 2;
10608
10648
  DISPOSITION_IGNORE = 1;
10609
10649
  DISPOSITION_HANDLER = 2;
10610
10650
  withBit = (mask, bit, on) => on ? mask | bit : mask & ~bit;
@@ -10621,6 +10661,7 @@ var init_wasi_signals = __esm({
10621
10661
  ignoring = 0;
10622
10662
  restarting = 0;
10623
10663
  defaults = 0;
10664
+ nocldwait = false;
10624
10665
  fallBack;
10625
10666
  onKilled;
10626
10667
  constructor(fallBack, onKilled) {
@@ -10646,6 +10687,7 @@ var init_wasi_signals = __esm({
10646
10687
  this.ignoring = withBit(this.ignoring, bit, disposition === DISPOSITION_IGNORE);
10647
10688
  this.restarting = withBit(this.restarting, bit, (flags & SA_RESTART) !== 0);
10648
10689
  this.defaults = withBit(this.defaults, bit, disposition === 0);
10690
+ if (sig === SIG.CHLD) this.nocldwait = (flags & SA_NOCLDWAIT) !== 0;
10649
10691
  return E.SUCCESS;
10650
10692
  }
10651
10693
  snapshot() {
@@ -10655,7 +10697,8 @@ var init_wasi_signals = __esm({
10655
10697
  handlers: this.handlers,
10656
10698
  ignoring: this.ignoring,
10657
10699
  restarting: this.restarting,
10658
- uncaught: this.uncaught
10700
+ uncaught: this.uncaught,
10701
+ ...this.nocldwait ? { nocldwait: true } : {}
10659
10702
  };
10660
10703
  }
10661
10704
  restore(state) {
@@ -10665,13 +10708,15 @@ var init_wasi_signals = __esm({
10665
10708
  this.ignoring = state.ignoring;
10666
10709
  this.restarting = state.restarting;
10667
10710
  this.uncaught = state.uncaught;
10711
+ this.nocldwait = state.nocldwait === true;
10668
10712
  }
10669
10713
  masks() {
10670
10714
  if (this.hooked) {
10671
10715
  const caught = this.handler() ? this.handlers : 0;
10672
10716
  const defaults = this.defaults;
10673
10717
  this.defaults = 0;
10674
- return { caught, ignored: this.ignoring, restart: this.restarting, defaults };
10718
+ const nocldwait = this.nocldwait ? { nocldwait: true } : {};
10719
+ return { caught, ignored: this.ignoring, restart: this.restarting, defaults, ...nocldwait };
10675
10720
  }
10676
10721
  if (!this.handler()) return null;
10677
10722
  return { caught: DELIVERED_MASK & ~this.uncaught & ~KERNEL_DEFAULTS, ignored: 0, restart: 0 };