@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.
@@ -846,7 +846,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
846
846
  symlink: (target, link) => mutating(() => bridge.symlink(target, link), ...entry(link)),
847
847
  chmod: (p, mode) => rewriting(p, () => bridge.chmod(p, mode)),
848
848
  utimes: (p, a, m, now2) => rewriting(p, () => bridge.utimes(p, a, m, now2)),
849
- lutimes: (p, a, m, now2) => mutating(() => bridge.lutimes(p, a, m, now2), p),
849
+ lutimes: (p, a, m, now2) => mutating(() => bridge.lutimes(p, a, m, now2)),
850
850
  ...bridge.hold ? { hold: bridge.hold.bind(bridge) } : {},
851
851
  ...bridge.access ? { access: bridge.access.bind(bridge) } : {},
852
852
  ...bridge.kept ? { kept: bridge.kept.bind(bridge) } : {},
@@ -887,7 +887,7 @@ function pinnedIo(bridge, handle, rewriting) {
887
887
  } : {}
888
888
  };
889
889
  }
890
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, SHARED_IDS_BYTES, StatCache;
890
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, SHARED_IDS_BYTES, StatCache;
891
891
  var init_wasi_files = __esm({
892
892
  "src/process/wasi/wasi-files.ts"() {
893
893
  "use strict";
@@ -1108,6 +1108,7 @@ var init_wasi_files = __esm({
1108
1108
  };
1109
1109
  MAX_LINKS = 40;
1110
1110
  MISS_TTL_MS = 20;
1111
+ CACHE_CAP = 8192;
1111
1112
  FS_GEN = 4;
1112
1113
  CRED_GEN = 5;
1113
1114
  RING = 8;
@@ -1119,6 +1120,7 @@ var init_wasi_files = __esm({
1119
1120
  lstats = /* @__PURE__ */ new Map();
1120
1121
  byHash = /* @__PURE__ */ new Map();
1121
1122
  byIno = /* @__PURE__ */ new Map();
1123
+ missed = /* @__PURE__ */ new Map();
1122
1124
  shared;
1123
1125
  seen;
1124
1126
  constructor(shared) {
@@ -1126,7 +1128,14 @@ var init_wasi_files = __esm({
1126
1128
  this.seen = shared ? Atomics.load(shared, FS_GEN) : 0;
1127
1129
  }
1128
1130
  put(map, path, entry) {
1131
+ if (this.stats.size + this.lstats.size + this.byHash.size + this.byIno.size >= CACHE_CAP)
1132
+ this.clear();
1129
1133
  map.set(path, entry);
1134
+ if ("until" in entry) {
1135
+ const paths = this.missed.get(map) ?? /* @__PURE__ */ new Set();
1136
+ paths.add(path);
1137
+ this.missed.set(map, paths);
1138
+ }
1130
1139
  if (!this.shared) return;
1131
1140
  index(this.byHash, pathHash(path), path);
1132
1141
  const ino = inoKey(entry);
@@ -1153,12 +1162,21 @@ var init_wasi_files = __esm({
1153
1162
  this.lstats.delete(path);
1154
1163
  }
1155
1164
  mutated(paths, ino = 0) {
1156
- this.clear();
1157
- if (!this.shared) return;
1158
1165
  const key = ino % 4294967296 | 0;
1166
+ if (paths.length === 0 || !this.shared) this.clear();
1167
+ if (!this.shared) return;
1159
1168
  for (const [i, hash] of (paths.length > 0 ? paths.map(pathHash) : [0]).entries()) {
1160
- this.seen = this.publish(this.shared, hash, i === 0 ? key : 0);
1169
+ const g = this.publish(this.shared, hash, i === 0 ? key : 0);
1170
+ if (paths.length > 0) this.replay(g - 1);
1171
+ this.seen = g;
1161
1172
  }
1173
+ if (paths.length === 0) return;
1174
+ for (const [i, path] of paths.entries()) {
1175
+ this.stats.delete(path);
1176
+ this.lstats.delete(path);
1177
+ this.drop(pathHash(path), i === 0 ? key : 0);
1178
+ }
1179
+ this.forgetMisses();
1162
1180
  }
1163
1181
  inoOf(path, look) {
1164
1182
  if (!this.shared) return 0;
@@ -1206,7 +1224,14 @@ var init_wasi_files = __esm({
1206
1224
  this.byHash.delete(hash);
1207
1225
  if (ino !== 0) this.byIno.delete(ino);
1208
1226
  }
1227
+ forgetMisses() {
1228
+ for (const [map, paths] of this.missed) {
1229
+ for (const path of paths) if ("until" in (map.get(path) ?? {})) map.delete(path);
1230
+ }
1231
+ this.missed.clear();
1232
+ }
1209
1233
  clear() {
1234
+ this.missed.clear();
1210
1235
  this.stats.clear();
1211
1236
  this.lstats.clear();
1212
1237
  this.byHash.clear();
@@ -2831,6 +2856,136 @@ var init_wasi_poll = __esm({
2831
2856
  }
2832
2857
  });
2833
2858
 
2859
+ // src/process/wasi/wasi-sigmask.ts
2860
+ var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER, NS_PER_MS2, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
2861
+ var init_wasi_sigmask = __esm({
2862
+ "src/process/wasi/wasi-sigmask.ts"() {
2863
+ "use strict";
2864
+ init_signals();
2865
+ init_sync_sab_wire();
2866
+ init_wasi_abi();
2867
+ UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
2868
+ LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
2869
+ FOREVER = 0xffffffffffffffffn;
2870
+ NS_PER_MS2 = 1000000n;
2871
+ POLL_MS = 50;
2872
+ SIG_BLOCK = 0;
2873
+ SIG_UNBLOCK = 1;
2874
+ SIG_SETMASK = 2;
2875
+ kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
2876
+ libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
2877
+ apply = (how, mask, set) => {
2878
+ if (how === SIG_BLOCK) return mask | set;
2879
+ if (how === SIG_UNBLOCK) return mask & ~set;
2880
+ return set;
2881
+ };
2882
+ WasiSigmask = class {
2883
+ lo;
2884
+ hi;
2885
+ header;
2886
+ deliver;
2887
+ process;
2888
+ tid;
2889
+ constructor(header, deliver, process, tid = 1) {
2890
+ this.header = header;
2891
+ this.deliver = deliver;
2892
+ this.process = process;
2893
+ this.tid = tid;
2894
+ this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
2895
+ this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
2896
+ }
2897
+ static unsupported(header) {
2898
+ storeBlocked(header, [0, 0]);
2899
+ }
2900
+ set(how, setLo, setHi, old) {
2901
+ if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
2902
+ old(this.lo >>> 0, this.hi >>> 0);
2903
+ this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
2904
+ this.hi = apply(how, this.hi, setHi | 0);
2905
+ const now = kernelBits(this.lo);
2906
+ storeBlocked(this.header, [now, this.hi]);
2907
+ if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
2908
+ return E.SUCCESS;
2909
+ }
2910
+ swap(setLo, setHi) {
2911
+ const old = [this.lo, this.hi];
2912
+ this.lo = setLo & ~LIBC_UNBLOCKABLE;
2913
+ this.hi = setHi | 0;
2914
+ storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
2915
+ return old;
2916
+ }
2917
+ deliverUnblocked() {
2918
+ const now = Atomics.load(this.header, SAB_I_BLOCKED);
2919
+ if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
2920
+ this.deliver();
2921
+ return true;
2922
+ }
2923
+ restore([lo, hi]) {
2924
+ this.set(SIG_SETMASK, lo, hi, () => {
2925
+ });
2926
+ }
2927
+ blockedBits() {
2928
+ return Atomics.load(this.header, SAB_I_BLOCKED);
2929
+ }
2930
+ blocks(sig) {
2931
+ return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
2932
+ }
2933
+ inherited() {
2934
+ return [kernelBits(this.lo), this.hi];
2935
+ }
2936
+ discard(sig) {
2937
+ Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
2938
+ if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
2939
+ }
2940
+ sigwait(setLo, timeoutNs, publish, took, entered = false) {
2941
+ const set = kernelBits(setLo | 0);
2942
+ const value2 = BigInt.asUintN(64, timeoutNs);
2943
+ const deadline = value2 === FOREVER ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS2 - 1n) / NS_PER_MS2);
2944
+ publish(set);
2945
+ try {
2946
+ for (; ; ) {
2947
+ const seen = Atomics.load(this.header, SAB_I_SIGNALS);
2948
+ const sig = this.take(set);
2949
+ if (sig !== 0) {
2950
+ took(sig);
2951
+ return E.SUCCESS;
2952
+ }
2953
+ if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
2954
+ const left = deadline - performance.now();
2955
+ if (left <= 0) return E.AGAIN;
2956
+ Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
2957
+ }
2958
+ } finally {
2959
+ publish(0);
2960
+ }
2961
+ }
2962
+ take(set) {
2963
+ for (const header of this.process ? [this.header, this.process] : [this.header]) {
2964
+ const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
2965
+ if (ready === 0) continue;
2966
+ const bit = ready & -ready;
2967
+ if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
2968
+ }
2969
+ return 0;
2970
+ }
2971
+ interrupted() {
2972
+ const killed = this.process ?? this.header;
2973
+ if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
2974
+ this.deliver();
2975
+ return true;
2976
+ }
2977
+ if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
2978
+ while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
2979
+ return true;
2980
+ }
2981
+ pending() {
2982
+ const own = Atomics.load(this.header, SAB_I_SIGNALS);
2983
+ return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
2984
+ }
2985
+ };
2986
+ }
2987
+ });
2988
+
2834
2989
  // src/process/wasi/wasi-termios.ts
2835
2990
  function writeTermios(mem, ptr, termios) {
2836
2991
  mem.bytes(ptr, OSPEED + 4).fill(0);
@@ -2909,8 +3064,8 @@ var init_wasi_termios = __esm({
2909
3064
  // src/process/wasi/wasix-epoll.ts
2910
3065
  function timeoutMs(ns) {
2911
3066
  const value2 = BigInt.asUintN(64, ns);
2912
- if (value2 === FOREVER) return -1;
2913
- const ms = (value2 + NS_PER_MS2 - 1n) / NS_PER_MS2;
3067
+ if (value2 === FOREVER2) return -1;
3068
+ const ms = (value2 + NS_PER_MS3 - 1n) / NS_PER_MS3;
2914
3069
  return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
2915
3070
  }
2916
3071
  function wasixEpollImports(host) {
@@ -2971,7 +3126,7 @@ function wasixEpollImports(host) {
2971
3126
  }
2972
3127
  };
2973
3128
  }
2974
- 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;
3129
+ 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;
2975
3130
  var init_wasix_epoll = __esm({
2976
3131
  "src/process/wasi/wasix-epoll.ts"() {
2977
3132
  "use strict";
@@ -2981,9 +3136,9 @@ var init_wasix_epoll = __esm({
2981
3136
  DATA_OFFSET = 8;
2982
3137
  DATA_SIZE = 24;
2983
3138
  MAX_EVENTS = 4096;
2984
- FOREVER = 0xffffffffffffffffn;
3139
+ FOREVER2 = 0xffffffffffffffffn;
2985
3140
  MAX_TIMEOUT_MS = 2147483647;
2986
- NS_PER_MS2 = 1000000n;
3141
+ NS_PER_MS3 = 1000000n;
2987
3142
  EVENTFD_SEMAPHORE = 1;
2988
3143
  EVENTFD_NONBLOCK = 4;
2989
3144
  EVENTFD_MAX = 0xfffffffffffffffen;
@@ -3424,7 +3579,7 @@ function filestatOf(path, s) {
3424
3579
  size: BigInt(s.size),
3425
3580
  ino: s.ino !== void 0 ? BigInt(s.ino) : pathInode(path),
3426
3581
  ...s.nlink !== void 0 ? { nlink: BigInt(s.nlink) } : {},
3427
- mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS3
3582
+ mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS4
3428
3583
  };
3429
3584
  }
3430
3585
  function kernelFiletype(kind) {
@@ -3474,7 +3629,7 @@ function wrap(table) {
3474
3629
  }
3475
3630
  return out;
3476
3631
  }
3477
- var WasiExit, IDS, NS_PER_MS3, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
3632
+ var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
3478
3633
  var init_wasi_host = __esm({
3479
3634
  "src/process/wasi/wasi-host.ts"() {
3480
3635
  "use strict";
@@ -3491,6 +3646,7 @@ var init_wasi_host = __esm({
3491
3646
  init_wasi_files();
3492
3647
  init_wasi_memory();
3493
3648
  init_wasi_poll();
3649
+ init_wasi_sigmask();
3494
3650
  init_wasi_termios();
3495
3651
  init_wasix_epoll();
3496
3652
  init_wasix_sockets();
@@ -3502,14 +3658,14 @@ var init_wasi_host = __esm({
3502
3658
  }
3503
3659
  };
3504
3660
  IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
3505
- NS_PER_MS3 = 1000000n;
3661
+ NS_PER_MS4 = 1000000n;
3506
3662
  AT_SYMLINK_NOFOLLOW = 1;
3507
3663
  AT_EACCESS = 2;
3508
3664
  ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
3509
3665
  GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
3510
3666
  S_IFIFO = 4096;
3511
3667
  DEFAULT_UMASK = 18;
3512
- MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS3;
3668
+ MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
3513
3669
  MAX_READ = 1024 * 1024;
3514
3670
  SIGPIPE_EXIT = 128 + SIG.PIPE;
3515
3671
  SIG_IGN = 1;
@@ -3786,6 +3942,11 @@ var init_wasi_host = __esm({
3786
3942
  this.entered
3787
3943
  );
3788
3944
  },
3945
+ sigaction_inherited: (out) => {
3946
+ const bits = this.o.kernel.call({ op: "sig-inherited" });
3947
+ mem.view().setBigUint64(out, BigInt(libcBits(bits) >>> 0), true);
3948
+ return E.SUCCESS;
3949
+ },
3789
3950
  sigpending_get: (out) => {
3790
3951
  if (!this.sigmask) return E.NOSYS;
3791
3952
  mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
@@ -3865,7 +4026,7 @@ var init_wasi_host = __esm({
3865
4026
  return this.cache;
3866
4027
  }
3867
4028
  now(id) {
3868
- if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS3;
4029
+ if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS4;
3869
4030
  if (id === CLOCK.MONOTONIC) {
3870
4031
  return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
3871
4032
  }
@@ -4406,7 +4567,7 @@ var init_wasi_host = __esm({
4406
4567
  current ??= statOf(path);
4407
4568
  return current[field2] ?? current.mtimeMs ?? now;
4408
4569
  };
4409
- const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS3) : kept(field2);
4570
+ const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS4) : kept(field2);
4410
4571
  (follow2 ? this.o.fs.utimes : this.o.fs.lutimes).call(
4411
4572
  this.o.fs,
4412
4573
  path,
@@ -5006,7 +5167,7 @@ var KERNEL_VERSION, OS_RELEASE;
5006
5167
  var init_version = __esm({
5007
5168
  "src/version.ts"() {
5008
5169
  "use strict";
5009
- KERNEL_VERSION = true ? "1.107.0" : "0.0.0-dev";
5170
+ KERNEL_VERSION = true ? "1.108.0" : "0.0.0-dev";
5010
5171
  OS_RELEASE = "6.0.0-slicc";
5011
5172
  }
5012
5173
  });
@@ -12587,7 +12748,7 @@ var init_process_signals = __esm({
12587
12748
  init_signals();
12588
12749
  init_sync_sab_wire();
12589
12750
  SignalGate = class {
12590
- reported = { caught: 0, ignored: 0 };
12751
+ reported = { caught: 0, ignored: 0, nocldwait: false };
12591
12752
  restart = 0;
12592
12753
  lastDelivered = 0;
12593
12754
  depth = 0;
@@ -12640,10 +12801,18 @@ var init_process_signals = __esm({
12640
12801
  if (!masks) return;
12641
12802
  this.restart = masks.restart;
12642
12803
  const { caught, ignored, defaults = 0 } = masks;
12643
- const same = caught === this.reported.caught && ignored === this.reported.ignored;
12804
+ const nocldwait = masks.nocldwait === true;
12805
+ const was = this.reported;
12806
+ const same = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
12644
12807
  if (same && defaults === 0) return;
12645
- this.reported = { caught, ignored };
12646
- const req = { op: "sig-mask", caught, ignored, ...defaults ? { defaults } : {} };
12808
+ this.reported = { caught, ignored, nocldwait };
12809
+ const req = {
12810
+ op: "sig-mask",
12811
+ caught,
12812
+ ignored,
12813
+ ...defaults ? { defaults } : {},
12814
+ ...nocldwait ? { nocldwait } : {}
12815
+ };
12647
12816
  this.raw.call(req, Number.POSITIVE_INFINITY, "sig-mask");
12648
12817
  }
12649
12818
  quiet(fn) {
@@ -13594,138 +13763,8 @@ var init_wasi_module = __esm({
13594
13763
  }
13595
13764
  });
13596
13765
 
13597
- // src/process/wasi/wasi-sigmask.ts
13598
- var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER2, NS_PER_MS4, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
13599
- var init_wasi_sigmask = __esm({
13600
- "src/process/wasi/wasi-sigmask.ts"() {
13601
- "use strict";
13602
- init_signals();
13603
- init_sync_sab_wire();
13604
- init_wasi_abi();
13605
- UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
13606
- LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
13607
- FOREVER2 = 0xffffffffffffffffn;
13608
- NS_PER_MS4 = 1000000n;
13609
- POLL_MS = 50;
13610
- SIG_BLOCK = 0;
13611
- SIG_UNBLOCK = 1;
13612
- SIG_SETMASK = 2;
13613
- kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
13614
- libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
13615
- apply = (how, mask, set) => {
13616
- if (how === SIG_BLOCK) return mask | set;
13617
- if (how === SIG_UNBLOCK) return mask & ~set;
13618
- return set;
13619
- };
13620
- WasiSigmask = class {
13621
- lo;
13622
- hi;
13623
- header;
13624
- deliver;
13625
- process;
13626
- tid;
13627
- constructor(header, deliver, process, tid = 1) {
13628
- this.header = header;
13629
- this.deliver = deliver;
13630
- this.process = process;
13631
- this.tid = tid;
13632
- this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
13633
- this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
13634
- }
13635
- static unsupported(header) {
13636
- storeBlocked(header, [0, 0]);
13637
- }
13638
- set(how, setLo, setHi, old) {
13639
- if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
13640
- old(this.lo >>> 0, this.hi >>> 0);
13641
- this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
13642
- this.hi = apply(how, this.hi, setHi | 0);
13643
- const now = kernelBits(this.lo);
13644
- storeBlocked(this.header, [now, this.hi]);
13645
- if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
13646
- return E.SUCCESS;
13647
- }
13648
- swap(setLo, setHi) {
13649
- const old = [this.lo, this.hi];
13650
- this.lo = setLo & ~LIBC_UNBLOCKABLE;
13651
- this.hi = setHi | 0;
13652
- storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
13653
- return old;
13654
- }
13655
- deliverUnblocked() {
13656
- const now = Atomics.load(this.header, SAB_I_BLOCKED);
13657
- if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
13658
- this.deliver();
13659
- return true;
13660
- }
13661
- restore([lo, hi]) {
13662
- this.set(SIG_SETMASK, lo, hi, () => {
13663
- });
13664
- }
13665
- blockedBits() {
13666
- return Atomics.load(this.header, SAB_I_BLOCKED);
13667
- }
13668
- blocks(sig) {
13669
- return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
13670
- }
13671
- inherited() {
13672
- return [kernelBits(this.lo), this.hi];
13673
- }
13674
- discard(sig) {
13675
- Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
13676
- if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
13677
- }
13678
- sigwait(setLo, timeoutNs, publish, took, entered = false) {
13679
- const set = kernelBits(setLo | 0);
13680
- const value2 = BigInt.asUintN(64, timeoutNs);
13681
- const deadline = value2 === FOREVER2 ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS4 - 1n) / NS_PER_MS4);
13682
- publish(set);
13683
- try {
13684
- for (; ; ) {
13685
- const seen = Atomics.load(this.header, SAB_I_SIGNALS);
13686
- const sig = this.take(set);
13687
- if (sig !== 0) {
13688
- took(sig);
13689
- return E.SUCCESS;
13690
- }
13691
- if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
13692
- const left = deadline - performance.now();
13693
- if (left <= 0) return E.AGAIN;
13694
- Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
13695
- }
13696
- } finally {
13697
- publish(0);
13698
- }
13699
- }
13700
- take(set) {
13701
- for (const header of this.process ? [this.header, this.process] : [this.header]) {
13702
- const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
13703
- if (ready === 0) continue;
13704
- const bit = ready & -ready;
13705
- if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
13706
- }
13707
- return 0;
13708
- }
13709
- interrupted() {
13710
- const killed = this.process ?? this.header;
13711
- if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
13712
- this.deliver();
13713
- return true;
13714
- }
13715
- if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
13716
- while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
13717
- return true;
13718
- }
13719
- pending() {
13720
- const own = Atomics.load(this.header, SAB_I_SIGNALS);
13721
- return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
13722
- }
13723
- };
13724
- }
13725
- });
13726
-
13727
13766
  // src/process/wasi/wasi-signals.ts
13728
- var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
13767
+ var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, SA_NOCLDWAIT, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
13729
13768
  var init_wasi_signals = __esm({
13730
13769
  "src/process/wasi/wasi-signals.ts"() {
13731
13770
  "use strict";
@@ -13736,6 +13775,7 @@ var init_wasi_signals = __esm({
13736
13775
  KERNEL_DEFAULTS = [SIG.TSTP, SIG.TTIN, SIG.TTOU, SIG.CHLD, SIG.CONT, SIG.URG, SIG.WINCH].map(sigbit).reduce((m, bit) => m | bit, 0);
13737
13776
  LIBC_DEFAULT_EXIT = 127;
13738
13777
  SA_RESTART = 268435456;
13778
+ SA_NOCLDWAIT = 2;
13739
13779
  DISPOSITION_IGNORE = 1;
13740
13780
  DISPOSITION_HANDLER = 2;
13741
13781
  withBit = (mask, bit, on) => on ? mask | bit : mask & ~bit;
@@ -13752,6 +13792,7 @@ var init_wasi_signals = __esm({
13752
13792
  ignoring = 0;
13753
13793
  restarting = 0;
13754
13794
  defaults = 0;
13795
+ nocldwait = false;
13755
13796
  fallBack;
13756
13797
  onKilled;
13757
13798
  constructor(fallBack, onKilled) {
@@ -13777,6 +13818,7 @@ var init_wasi_signals = __esm({
13777
13818
  this.ignoring = withBit(this.ignoring, bit, disposition === DISPOSITION_IGNORE);
13778
13819
  this.restarting = withBit(this.restarting, bit, (flags & SA_RESTART) !== 0);
13779
13820
  this.defaults = withBit(this.defaults, bit, disposition === 0);
13821
+ if (sig === SIG.CHLD) this.nocldwait = (flags & SA_NOCLDWAIT) !== 0;
13780
13822
  return E.SUCCESS;
13781
13823
  }
13782
13824
  snapshot() {
@@ -13786,7 +13828,8 @@ var init_wasi_signals = __esm({
13786
13828
  handlers: this.handlers,
13787
13829
  ignoring: this.ignoring,
13788
13830
  restarting: this.restarting,
13789
- uncaught: this.uncaught
13831
+ uncaught: this.uncaught,
13832
+ ...this.nocldwait ? { nocldwait: true } : {}
13790
13833
  };
13791
13834
  }
13792
13835
  restore(state) {
@@ -13796,13 +13839,15 @@ var init_wasi_signals = __esm({
13796
13839
  this.ignoring = state.ignoring;
13797
13840
  this.restarting = state.restarting;
13798
13841
  this.uncaught = state.uncaught;
13842
+ this.nocldwait = state.nocldwait === true;
13799
13843
  }
13800
13844
  masks() {
13801
13845
  if (this.hooked) {
13802
13846
  const caught = this.handler() ? this.handlers : 0;
13803
13847
  const defaults = this.defaults;
13804
13848
  this.defaults = 0;
13805
- return { caught, ignored: this.ignoring, restart: this.restarting, defaults };
13849
+ const nocldwait = this.nocldwait ? { nocldwait: true } : {};
13850
+ return { caught, ignored: this.ignoring, restart: this.restarting, defaults, ...nocldwait };
13806
13851
  }
13807
13852
  if (!this.handler()) return null;
13808
13853
  return { caught: DELIVERED_MASK & ~this.uncaught & ~KERNEL_DEFAULTS, ignored: 0, restart: 0 };