@ai-ecoverse/slicc-kernel 1.87.0 → 1.88.1

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.
@@ -144,11 +144,11 @@ function sabViews(sab) {
144
144
  window: new Uint8Array(sab, SAB_HEADER_BYTES)
145
145
  };
146
146
  }
147
- var SAB_HEADER_I32, SAB_CLOCK_OFFSET, SAB_CLOCK_I64, SAB_HEADER_BYTES, SAB_I_STATE, SAB_I_SEQ, SAB_I_STATUS, SAB_I_TOTAL, SAB_I_CHUNK, SAB_I_OFFSET, SAB_I_REQ, SAB_I_PUB, SAB_I_SIGNALS, SAB_I_TIMERS, SAB_I_MEMORY, SAB_I_TOTAL_HI, SAB_I_OFFSET_HI, SAB_I_KILLED, SAB_I_ASYNC, SAB_I_STOP, U32, SAB_STATE_IDLE, SAB_STATE_PENDING, SAB_STATE_READY, SAB_STATUS_BYTES, SAB_STATUS_JSON, SAB_STATUS_VOID, SAB_STATUS_ERRNO, SAB_DEFAULT_WINDOW_BYTES, SAB_MIN_BYTES, SYNC_SAB_REQ_MSG, SYNC_SAB_NEXT_MSG, encoder, decoder;
147
+ var SAB_HEADER_I32, SAB_CLOCK_OFFSET, SAB_CLOCK_I64, SAB_HEADER_BYTES, SAB_I_STATE, SAB_I_SEQ, SAB_I_STATUS, SAB_I_TOTAL, SAB_I_CHUNK, SAB_I_OFFSET, SAB_I_REQ, SAB_I_PUB, SAB_I_SIGNALS, SAB_I_TIMERS, SAB_I_MEMORY, SAB_I_TOTAL_HI, SAB_I_OFFSET_HI, SAB_I_KILLED, SAB_I_ASYNC, SAB_I_STOP, SAB_I_BLOCKED, U32, SAB_STATE_IDLE, SAB_STATE_PENDING, SAB_STATE_READY, SAB_STATUS_BYTES, SAB_STATUS_JSON, SAB_STATUS_VOID, SAB_STATUS_ERRNO, SAB_DEFAULT_WINDOW_BYTES, SAB_MIN_BYTES, SYNC_SAB_REQ_MSG, SYNC_SAB_NEXT_MSG, encoder, decoder;
148
148
  var init_sync_sab_wire = __esm({
149
149
  "src/realm/sync-sab-wire.ts"() {
150
150
  "use strict";
151
- SAB_HEADER_I32 = 16;
151
+ SAB_HEADER_I32 = 18;
152
152
  SAB_CLOCK_OFFSET = SAB_HEADER_I32 * 4;
153
153
  SAB_CLOCK_I64 = 3;
154
154
  SAB_HEADER_BYTES = SAB_CLOCK_OFFSET + SAB_CLOCK_I64 * 8;
@@ -168,6 +168,7 @@ var init_sync_sab_wire = __esm({
168
168
  SAB_I_KILLED = 13;
169
169
  SAB_I_ASYNC = 14;
170
170
  SAB_I_STOP = 15;
171
+ SAB_I_BLOCKED = 16;
171
172
  U32 = 2 ** 32;
172
173
  SAB_STATE_IDLE = 0;
173
174
  SAB_STATE_PENDING = 1;
@@ -3940,7 +3941,7 @@ var init_process_signals = __esm({
3940
3941
  interrupt() {
3941
3942
  this.report();
3942
3943
  const header = this.header;
3943
- const pending = Atomics.load(header, SAB_I_SIGNALS) | Atomics.load(header, SAB_I_TIMERS) | Atomics.load(header, SAB_I_KILLED);
3944
+ const pending = Atomics.load(header, SAB_I_SIGNALS) & ~Atomics.load(header, SAB_I_BLOCKED) | Atomics.load(header, SAB_I_TIMERS) | Atomics.load(header, SAB_I_KILLED);
3944
3945
  if (pending === 0) return false;
3945
3946
  this.deliver();
3946
3947
  return true;
@@ -3953,7 +3954,8 @@ var init_process_signals = __esm({
3953
3954
  this.hooks.killed(killed);
3954
3955
  }
3955
3956
  const timers = Atomics.exchange(this.header, SAB_I_TIMERS, 0);
3956
- const pending = Atomics.exchange(this.header, SAB_I_SIGNALS, 0);
3957
+ const blocked = Atomics.load(this.header, SAB_I_BLOCKED);
3958
+ const pending = blocked === 0 ? Atomics.exchange(this.header, SAB_I_SIGNALS, 0) : Atomics.and(this.header, SAB_I_SIGNALS, blocked) & ~blocked;
3957
3959
  if (this.depth <= 1) this.lastDelivered = pending | (timers & 1 ? sigbit(SIG.ALRM) : 0);
3958
3960
  if (pending !== 0 || timers !== 0) this.delivered++;
3959
3961
  for (let which = 0; which < 3; which++) {
@@ -4149,7 +4151,29 @@ var init_cred = __esm({
4149
4151
  }
4150
4152
  });
4151
4153
 
4154
+ // src/version.ts
4155
+ function procVersion() {
4156
+ return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
4157
+ `;
4158
+ }
4159
+ var KERNEL_VERSION, OS_RELEASE;
4160
+ var init_version = __esm({
4161
+ "src/version.ts"() {
4162
+ "use strict";
4163
+ KERNEL_VERSION = true ? "1.88.1" : "0.0.0-dev";
4164
+ OS_RELEASE = "6.0.0-slicc";
4165
+ }
4166
+ });
4167
+
4152
4168
  // src/process/procfs.ts
4169
+ function sysEntry(parts) {
4170
+ let at = SYS_TREE;
4171
+ for (const part of parts) {
4172
+ if (typeof at !== "object" || !Object.hasOwn(at, part)) return void 0;
4173
+ at = at[part];
4174
+ }
4175
+ return at;
4176
+ }
4153
4177
  function commOf(info) {
4154
4178
  const name2 = info.argv[0] ?? "";
4155
4179
  return name2.slice(name2.lastIndexOf("/") + 1).slice(0, 15);
@@ -4234,7 +4258,7 @@ function pidStatus(info) {
4234
4258
  "SigQ: 0/0",
4235
4259
  "SigPnd: 0000000000000000",
4236
4260
  "ShdPnd: 0000000000000000",
4237
- "SigBlk: 0000000000000000",
4261
+ `SigBlk: ${sigMask(info.sigBlk)}`,
4238
4262
  `SigIgn: ${sigMask(info.sigIgn)}`,
4239
4263
  `SigCgt: ${sigMask(info.sigCgt)}`,
4240
4264
  ""
@@ -4270,6 +4294,7 @@ function memoryInfo(source, used = 0) {
4270
4294
  ].map(([key, value2]) => `${`${key}:`.padEnd(16)}${value2.padStart(12)}`).concat("").join("\n");
4271
4295
  }
4272
4296
  function systemFile(name2, listing, now, memory) {
4297
+ if (name2 === "version") return procVersion();
4273
4298
  const up = Math.max(0, now - listing.boot) / 1e3;
4274
4299
  if (name2 === "uptime") return `${up.toFixed(2)} ${up.toFixed(2)}
4275
4300
  `;
@@ -4386,6 +4411,16 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
4386
4411
  if (!info) throw error();
4387
4412
  return pidFile(name2, info, listing.boot);
4388
4413
  };
4414
+ const sysDir = (parent, name2, tree) => {
4415
+ const dir = fresh(parent, name2, DIR_MODE2);
4416
+ dir.node_ops.lookup = (at, child) => {
4417
+ if (!Object.hasOwn(tree, child)) throw error();
4418
+ const next2 = tree[child];
4419
+ return typeof next2 === "string" ? file(at, child, () => next2) : sysDir(at, child, next2);
4420
+ };
4421
+ dir.node_ops.readdir = () => [".", "..", ...Object.keys(tree)];
4422
+ return dir;
4423
+ };
4389
4424
  const pidNames = (names) => [.../* @__PURE__ */ new Set([...names, ...PID_FILES])];
4390
4425
  const pidDir = (name2, target) => {
4391
4426
  const dir = fresh(proc, name2, DIR_MODE2);
@@ -4410,7 +4445,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
4410
4445
  const readdir = procOps.readdir?.bind(procOps);
4411
4446
  const listAll = (node) => {
4412
4447
  const names = new Set(readdir ? readdir(node) : [".", ".."]);
4413
- for (const name2 of [...SYSTEM_FILES, "mounts"]) names.add(name2);
4448
+ for (const name2 of [...SYSTEM_FILES, "mounts", "sys"]) names.add(name2);
4414
4449
  for (const p of procList().processes) names.add(String(p.pid));
4415
4450
  return [...names];
4416
4451
  };
@@ -4422,6 +4457,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
4422
4457
  return pidDir(name2, Number(name2));
4423
4458
  }
4424
4459
  if (name2 === "mounts") return file(parent, name2, () => mountTable(sys.mountList?.() ?? []));
4460
+ if (name2 === "sys") return sysDir(parent, name2, SYS_TREE);
4425
4461
  if (SYSTEM_FILES.includes(name2)) {
4426
4462
  return file(
4427
4463
  parent,
@@ -4485,11 +4521,12 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
4485
4521
  readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
4486
4522
  };
4487
4523
  }
4488
- var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask, STATES, tagLine;
4524
+ var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, SYS_TREE, sigMask, STATES, tagLine;
4489
4525
  var init_procfs = __esm({
4490
4526
  "src/process/procfs.ts"() {
4491
4527
  "use strict";
4492
4528
  init_cred();
4529
+ init_version();
4493
4530
  init_process_fds();
4494
4531
  HZ = 100;
4495
4532
  DIR_MODE2 = 16749;
@@ -4501,7 +4538,11 @@ var init_procfs = __esm({
4501
4538
  KIB = 1024;
4502
4539
  FALLBACK_MEMORY = 4 * KIB * KIB * KIB;
4503
4540
  PID_FILES = ["cmdline", "comm", "stat", "statm", "status"];
4504
- SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime"];
4541
+ SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime", "version"];
4542
+ SYS_TREE = {
4543
+ kernel: { osrelease: `${OS_RELEASE}
4544
+ `, ostype: "Linux\n" }
4545
+ };
4505
4546
  sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
4506
4547
  STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
4507
4548
  tagLine = (tag) => `Tag: ${tag.replaceAll("\n", "\\n").replaceAll(" ", "\\t").replaceAll("\r", "\\r")}`;
@@ -5580,9 +5621,9 @@ var init_wasi_files = __esm({
5580
5621
  readable;
5581
5622
  writable;
5582
5623
  append;
5583
- constructor(buffer, readable2, writable2, append) {
5624
+ constructor(buffer, readable3, writable2, append) {
5584
5625
  this.buffer = buffer;
5585
- this.readable = readable2;
5626
+ this.readable = readable3;
5586
5627
  this.writable = writable2;
5587
5628
  this.append = append;
5588
5629
  }
@@ -6404,7 +6445,7 @@ var init_wasi_fds = __esm({
6404
6445
  }
6405
6446
  }
6406
6447
  file(path, existing, oflags, rights, fdflags) {
6407
- const { readable: readable2, writable: writable2 } = openAccess(existing, oflags, rights);
6448
+ const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
6408
6449
  let buffer = this.buffers.get(path);
6409
6450
  if (buffer?.handle !== void 0 && this.fs.kept?.(buffer.handle)) {
6410
6451
  this.buffers.delete(path);
@@ -6419,7 +6460,7 @@ var init_wasi_fds = __esm({
6419
6460
  buffer = this.freshBuffer(path, existing, oflags, want);
6420
6461
  }
6421
6462
  buffer.opens++;
6422
- return new LocalFile(buffer, readable2, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
6463
+ return new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
6423
6464
  }
6424
6465
  freshBuffer(path, existing, oflags, want) {
6425
6466
  const made = !existing && this.createNew(path, oflags);
@@ -6438,9 +6479,9 @@ var init_wasi_fds = __esm({
6438
6479
  return buffer;
6439
6480
  }
6440
6481
  kernelFile(path, existing, oflags, rights, fdflags) {
6441
- const { readable: readable2, writable: writable2 } = openAccess(existing, oflags, rights);
6482
+ const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
6442
6483
  const append = (fdflags & FDFLAGS.APPEND) !== 0;
6443
- const flags = (writable2 ? readable2 ? O_RDWR4 : O_WRONLY4 : 0) | (append ? O_APPEND : 0);
6484
+ const flags = (writable2 ? readable3 ? O_RDWR4 : O_WRONLY4 : 0) | (append ? O_APPEND : 0);
6444
6485
  const made = !existing && this.createNew(path, oflags);
6445
6486
  const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
6446
6487
  const fd = this.kernel.sys.openVfs(path, flags, 0, {
@@ -6841,7 +6882,7 @@ function wrap(table) {
6841
6882
  }
6842
6883
  return out;
6843
6884
  }
6844
- var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SEALED_MODE, WasiHost;
6885
+ var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
6845
6886
  var init_wasi_host = __esm({
6846
6887
  "src/process/wasi/wasi-host.ts"() {
6847
6888
  "use strict";
@@ -6872,6 +6913,7 @@ var init_wasi_host = __esm({
6872
6913
  MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS;
6873
6914
  MAX_READ = 1024 * 1024;
6874
6915
  SIGPIPE_EXIT = 141;
6916
+ SIG_IGN = 1;
6875
6917
  SEALED_MODE = 8630;
6876
6918
  WasiHost = class {
6877
6919
  mem = new WasiMemory();
@@ -6883,6 +6925,7 @@ var init_wasi_host = __esm({
6883
6925
  onRaise;
6884
6926
  muted;
6885
6927
  signals;
6928
+ sigmask;
6886
6929
  interrupted;
6887
6930
  quietly = (fn) => fn();
6888
6931
  listening;
@@ -7074,7 +7117,23 @@ var init_wasi_host = __esm({
7074
7117
  const groups = Array.from({ length: n }, (_, i) => view.getUint32(buf + i * 4, true));
7075
7118
  void this.o.kernel.call({ op: "proc-setcred", change: { groups } });
7076
7119
  },
7077
- sigaction_set: (sig, disposition, flags) => this.signals ? this.signals.disposition(sig, disposition, flags) : E.NOSYS
7120
+ sigaction_set: (sig, disposition, flags) => {
7121
+ if (!this.signals) return E.NOSYS;
7122
+ const errno2 = this.signals.disposition(sig, disposition, flags);
7123
+ if (errno2 === E.SUCCESS && disposition === SIG_IGN) this.sigmask?.discard(sig);
7124
+ return errno2;
7125
+ },
7126
+ sigmask_set: (how, lo, hi, old) => this.sigmask ? this.sigmask.set(how, lo, hi, (oldLo, oldHi) => {
7127
+ if (old === 0) return;
7128
+ const view = mem.view();
7129
+ view.setUint32(old, oldLo, true);
7130
+ view.setUint32(old + 4, oldHi, true);
7131
+ }) : E.NOSYS,
7132
+ sigpending_get: (out) => {
7133
+ if (!this.sigmask) return E.NOSYS;
7134
+ mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
7135
+ return E.SUCCESS;
7136
+ }
7078
7137
  });
7079
7138
  }
7080
7139
  imports() {
@@ -7624,6 +7683,7 @@ var init_wasi_threads = __esm({
7624
7683
  beforeSpawn;
7625
7684
  modules;
7626
7685
  received;
7686
+ blocked;
7627
7687
  port;
7628
7688
  memory;
7629
7689
  cap;
@@ -7644,6 +7704,7 @@ var init_wasi_threads = __esm({
7644
7704
  this.beforeSpawn?.();
7645
7705
  const tid = Atomics.add(this.ids, LAST_TID, 1) + 1;
7646
7706
  const modules = this.modules?.();
7707
+ const blocked = this.blocked?.() ?? 0;
7647
7708
  this.port.postMessage({
7648
7709
  type: WASM_THREAD_SPAWN,
7649
7710
  thread: {
@@ -7651,7 +7712,8 @@ var init_wasi_threads = __esm({
7651
7712
  arg,
7652
7713
  memory: this.memory,
7653
7714
  ids: this.ids.buffer,
7654
- ...modules ? { modules } : {}
7715
+ ...modules ? { modules } : {},
7716
+ ...blocked ? { blocked } : {}
7655
7717
  }
7656
7718
  });
7657
7719
  return tid;
@@ -8392,11 +8454,17 @@ var init_wasi_procfs = __esm({
8392
8454
  names: () => [
8393
8455
  ...SYSTEM_NAMES,
8394
8456
  "mounts",
8457
+ "sys",
8395
8458
  "self",
8396
8459
  ...this.listing().processes.map((p) => String(p.pid))
8397
8460
  ]
8398
8461
  };
8399
8462
  }
8463
+ if (top === "sys") {
8464
+ const entry = sysEntry(parts.slice(1));
8465
+ if (typeof entry === "string") return { kind: "file", content: () => entry };
8466
+ return entry && { kind: "dir", names: () => Object.keys(entry) };
8467
+ }
8400
8468
  if (top === "self") {
8401
8469
  return leaf === void 0 ? { kind: "link", target: String(this.pid) } : void 0;
8402
8470
  }
@@ -8480,6 +8548,63 @@ var init_wasi_procfs = __esm({
8480
8548
  }
8481
8549
  });
8482
8550
 
8551
+ // src/process/wasi/wasi-sigmask.ts
8552
+ var UNBLOCKABLE, LIBC_UNBLOCKABLE, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
8553
+ var init_wasi_sigmask = __esm({
8554
+ "src/process/wasi/wasi-sigmask.ts"() {
8555
+ "use strict";
8556
+ init_signals();
8557
+ init_sync_sab_wire();
8558
+ init_wasi_abi();
8559
+ UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
8560
+ LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
8561
+ SIG_BLOCK = 0;
8562
+ SIG_UNBLOCK = 1;
8563
+ SIG_SETMASK = 2;
8564
+ kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
8565
+ libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
8566
+ apply = (how, mask, set) => {
8567
+ if (how === SIG_BLOCK) return mask | set;
8568
+ if (how === SIG_UNBLOCK) return mask & ~set;
8569
+ return set;
8570
+ };
8571
+ WasiSigmask = class {
8572
+ lo;
8573
+ hi = 0;
8574
+ header;
8575
+ deliver;
8576
+ process;
8577
+ constructor(header, deliver, process) {
8578
+ this.header = header;
8579
+ this.deliver = deliver;
8580
+ this.process = process;
8581
+ this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
8582
+ }
8583
+ static unsupported(header) {
8584
+ Atomics.store(header, SAB_I_BLOCKED, 0);
8585
+ }
8586
+ set(how, setLo, setHi, old) {
8587
+ if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
8588
+ old(this.lo >>> 0, this.hi >>> 0);
8589
+ this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
8590
+ this.hi = apply(how, this.hi, setHi | 0);
8591
+ const now = kernelBits(this.lo);
8592
+ Atomics.store(this.header, SAB_I_BLOCKED, now);
8593
+ if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
8594
+ return E.SUCCESS;
8595
+ }
8596
+ discard(sig) {
8597
+ Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
8598
+ if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
8599
+ }
8600
+ pending() {
8601
+ const own = Atomics.load(this.header, SAB_I_SIGNALS);
8602
+ return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
8603
+ }
8604
+ };
8605
+ }
8606
+ });
8607
+
8483
8608
  // src/process/wasi/wasi-signals.ts
8484
8609
  var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
8485
8610
  var init_wasi_signals = __esm({
@@ -8565,7 +8690,11 @@ var init_wasi_signals = __esm({
8565
8690
  }
8566
8691
  raise(sig) {
8567
8692
  const handler = this.handler();
8568
- if (!handler) return;
8693
+ if (!handler && !this.hooked) return;
8694
+ if (!handler || this.hooked && (this.handlers & sigbit(sig)) === 0) {
8695
+ if ((this.ignoring & sigbit(sig)) === 0) this.defaultAction(sig);
8696
+ return;
8697
+ }
8569
8698
  const outer = { sig: this.delivering, defaulted: this.defaulted, libc: this.libcDefault };
8570
8699
  this.delivering = sig;
8571
8700
  this.defaulted = false;
@@ -10442,6 +10571,7 @@ __export(wasi_runtime_exports, {
10442
10571
  delivering: () => delivering,
10443
10572
  runWasiProcess: () => runWasiProcess,
10444
10573
  runWasiThread: () => runWasiThread,
10574
+ sigmaskOf: () => sigmaskOf,
10445
10575
  trapMessage: () => trapMessage,
10446
10576
  unsupportedImport: () => unsupportedImport,
10447
10577
  wireSignals: () => wireSignals
@@ -10478,6 +10608,16 @@ function delivering(ns, table, host, driver, before) {
10478
10608
  }
10479
10609
  return out;
10480
10610
  }
10611
+ function sigmaskOf(module, sab, gate, threads, process) {
10612
+ const header = new Int32Array(sab, 0, SAB_HEADER_I32);
10613
+ if (!importsSlicc(module, "sigmask_set")) {
10614
+ WasiSigmask.unsupported(header);
10615
+ return void 0;
10616
+ }
10617
+ if (threads) threads.blocked = () => Atomics.load(header, SAB_I_BLOCKED);
10618
+ const shared = process && new Int32Array(process, 0, SAB_HEADER_I32);
10619
+ return new WasiSigmask(header, () => gate.deliver(), shared);
10620
+ }
10481
10621
  function enosys(module, name2, foreign) {
10482
10622
  const type = foreign?.[module]?.[name2];
10483
10623
  if (type === "other") throw new Error(noErrno(`${module}.${name2}`));
@@ -10791,6 +10931,7 @@ async function runWasiProcess(init, port2) {
10791
10931
  ),
10792
10932
  ...descriptors(init, fork, threads)
10793
10933
  });
10934
+ host.sigmask = sigmaskOf(module, init.sab, gate, threads);
10794
10935
  if (threads) {
10795
10936
  threads.beforeSpawn = () => {
10796
10937
  if (!host.fds.isShared) host.fds.share(threads.ids, false);
@@ -10885,6 +11026,7 @@ async function runWasiThread(init, port2) {
10885
11026
  ),
10886
11027
  shared: threads.ids
10887
11028
  });
11029
+ host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
10888
11030
  const program = await programImports(init.program, host, transport, thread.tid);
10889
11031
  const { instance } = await instantiate(host, init.program.module, thread.memory, threads, {
10890
11032
  thread: true,
@@ -10920,7 +11062,7 @@ async function runWasiThread(init, port2) {
10920
11062
  throw e;
10921
11063
  }
10922
11064
  }
10923
- var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, UNDELIVERED, DELIVERED, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
11065
+ var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, UNDELIVERED, DELIVERED, importsSlicc, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
10924
11066
  var init_wasi_runtime = __esm({
10925
11067
  "src/process/wasi/wasi-runtime.ts"() {
10926
11068
  "use strict";
@@ -10938,6 +11080,7 @@ var init_wasi_runtime = __esm({
10938
11080
  init_wasi_imports();
10939
11081
  init_wasi_module();
10940
11082
  init_wasi_procfs();
11083
+ init_wasi_sigmask();
10941
11084
  init_wasi_signals();
10942
11085
  init_wasi_stats();
10943
11086
  init_wasi_threads();
@@ -10964,7 +11107,8 @@ var init_wasi_runtime = __esm({
10964
11107
  wasi: ["thread-spawn"]
10965
11108
  };
10966
11109
  DELIVERED = [PREVIEW1, WASIX, SLICC, SLICC_FS, SLICC_TTY];
10967
- importsSigactionHook = (module) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === "sigaction_set");
11110
+ importsSlicc = (module, name2) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === name2);
11111
+ importsSigactionHook = (module) => importsSlicc(module, "sigaction_set");
10968
11112
  noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
10969
11113
  FALLBACK_MAXIMUM_PAGES = 32768;
10970
11114
  LinkSync = class {
@@ -11406,6 +11550,7 @@ function childOps(kernel, io, defaults, sync) {
11406
11550
  if (file === void 0) throw new JsCallError("EINVAL", "spawn");
11407
11551
  const group = groupOf(o, "spawn");
11408
11552
  const named = argv0Of(o.argv0, "spawn");
11553
+ const death = deathOf(o.parentDeathSignal, defaults);
11409
11554
  return (stdio) => ({
11410
11555
  op: "proc-spawn",
11411
11556
  file,
@@ -11414,7 +11559,8 @@ function childOps(kernel, io, defaults, sync) {
11414
11559
  env: { ...o.env ?? defaults.env },
11415
11560
  cwd: o.cwd ?? defaults.cwd,
11416
11561
  stdio,
11417
- ...group
11562
+ ...group,
11563
+ ...death
11418
11564
  });
11419
11565
  };
11420
11566
  const spawnSync = (o) => {
@@ -11457,6 +11603,13 @@ function groupOf(o, call2) {
11457
11603
  if (session && pgid !== void 0) throw new JsCallError("EINVAL", call2);
11458
11604
  return session ? { session: true } : pgid !== void 0 ? { pgid } : {};
11459
11605
  }
11606
+ function deathOf(signal, defaults) {
11607
+ if (signal === void 0) return {};
11608
+ if (typeof signal !== "number" && typeof signal !== "string") {
11609
+ throw new JsCallError("EINVAL", "spawn");
11610
+ }
11611
+ return { deathSignal: defaults.signal(signal) };
11612
+ }
11460
11613
  function argv0Of(argv0, call2) {
11461
11614
  if (argv0 === void 0) return {};
11462
11615
  if (typeof argv0 !== "string") throw new JsCallError("EINVAL", call2);
@@ -12416,7 +12569,7 @@ function netOps(kernel, io) {
12416
12569
  return closed;
12417
12570
  };
12418
12571
  const shut = (how) => kernel.raw({ op: "sock-shutdown", fd, how });
12419
- const readable2 = new ReadableStream(
12572
+ const readable3 = new ReadableStream(
12420
12573
  {
12421
12574
  async pull(controller) {
12422
12575
  const chunk = await io.read(fd, void 0, stop.signal);
@@ -12432,7 +12585,7 @@ function netOps(kernel, io) {
12432
12585
  close: async () => void await shut(SHUT_WR),
12433
12586
  abort: () => close()
12434
12587
  });
12435
- return { fd, local: local2, remote, readable: readable2, writable: writable2, close };
12588
+ return { fd, local: local2, remote, readable: readable3, writable: writable2, close };
12436
12589
  };
12437
12590
  const resolve = async (host, signal) => {
12438
12591
  if (IPV4.test(host)) return host;
@@ -13045,7 +13198,7 @@ function websocketOp(kernel) {
13045
13198
  reason: closeReason(how.reason)
13046
13199
  });
13047
13200
  };
13048
- const readable2 = new ReadableStream(
13201
+ const readable3 = new ReadableStream(
13049
13202
  {
13050
13203
  async pull(controller) {
13051
13204
  let r;
@@ -13095,7 +13248,7 @@ function websocketOp(kernel) {
13095
13248
  close: () => close(),
13096
13249
  abort: () => close({ code: 1e3, reason: "" })
13097
13250
  });
13098
- return { url, protocol, readable: readable2, writable: writable2, closed, close };
13251
+ return { url, protocol, readable: readable3, writable: writable2, closed, close };
13099
13252
  };
13100
13253
  }
13101
13254
  var SEND_BUFFER, MAX_REASON, NEVER2, wait;
@@ -13128,9 +13281,11 @@ function signalNumber(signal) {
13128
13281
  if (Number.isInteger(signal) && signal >= 1 && signal <= 31) return signal;
13129
13282
  throw new JsCallError("EINVAL", `signal ${signal}`);
13130
13283
  }
13131
- const n = SIG[signal.slice(3)];
13132
- if (n === void 0) throw new JsCallError("EINVAL", `signal ${signal}`);
13133
- return n;
13284
+ const name2 = signal.slice(3);
13285
+ if (!signal.startsWith("SIG") || !Object.hasOwn(SIG, name2)) {
13286
+ throw new JsCallError("EINVAL", `signal ${signal}`);
13287
+ }
13288
+ return SIG[name2];
13134
13289
  }
13135
13290
  function resolvePath(cwd, path) {
13136
13291
  const parts = [];
@@ -13200,6 +13355,18 @@ function writer(kernel, info, pid) {
13200
13355
  };
13201
13356
  return { writes, writeAll };
13202
13357
  }
13358
+ function readable2(read2) {
13359
+ return new ReadableStream(
13360
+ {
13361
+ async pull(controller) {
13362
+ const chunk = await read2(0);
13363
+ if (chunk.length === 0) controller.close();
13364
+ else controller.enqueue(chunk);
13365
+ }
13366
+ },
13367
+ { highWaterMark: 0 }
13368
+ );
13369
+ }
13203
13370
  function createContext(o) {
13204
13371
  const { kernel } = o;
13205
13372
  const infos = /* @__PURE__ */ new Map();
@@ -13280,6 +13447,7 @@ function createContext(o) {
13280
13447
  const syncKernel = new JsSyncKernel(lane, kernel, unwind);
13281
13448
  const terminal = ttyOps(kernel);
13282
13449
  const sync = {
13450
+ kernel: KERNEL_INFO,
13283
13451
  ...syncOps(syncKernel, { pid: o.pid, resolve, random, infos, handles }),
13284
13452
  run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
13285
13453
  spawn: (options) => spawnSync(options),
@@ -13301,6 +13469,7 @@ function createContext(o) {
13301
13469
  const { spawnSync, ...children } = childOps(kernel, io, defaults, syncKernel);
13302
13470
  const strays = o.strays ?? { exception: /* @__PURE__ */ new Set(), rejection: /* @__PURE__ */ new Set() };
13303
13471
  const ctx = {
13472
+ kernel: KERNEL_INFO,
13304
13473
  argv: o.argv,
13305
13474
  env: o.env,
13306
13475
  pid: o.pid,
@@ -13308,16 +13477,7 @@ function createContext(o) {
13308
13477
  return identityOf(await kernel.json({ op: "proc-identity" }), o).ppid;
13309
13478
  },
13310
13479
  cwd: o.cwd,
13311
- stdin: new ReadableStream(
13312
- {
13313
- async pull(controller) {
13314
- const chunk = await read2(0);
13315
- if (chunk.length === 0) controller.close();
13316
- else controller.enqueue(chunk);
13317
- }
13318
- },
13319
- { highWaterMark: 0 }
13320
- ),
13480
+ stdin: readable2(read2),
13321
13481
  stdout: writable2(1),
13322
13482
  stderr: writable2(2),
13323
13483
  read: read2,
@@ -13526,12 +13686,13 @@ function pathOps(kernel, resolve, statOf, open) {
13526
13686
  }
13527
13687
  };
13528
13688
  }
13529
- var JsExit, encoder4;
13689
+ var KERNEL_INFO, JsExit, encoder4;
13530
13690
  var init_js_context = __esm({
13531
13691
  "src/process/js/js-context.ts"() {
13532
13692
  "use strict";
13533
13693
  init_signals();
13534
13694
  init_sync_fs_wire();
13695
+ init_version();
13535
13696
  init_js_children();
13536
13697
  init_js_dev();
13537
13698
  init_js_exit();
@@ -13543,6 +13704,7 @@ var init_js_context = __esm({
13543
13704
  init_js_sync();
13544
13705
  init_js_tty();
13545
13706
  init_js_websocket();
13707
+ KERNEL_INFO = Object.freeze({ version: KERNEL_VERSION });
13546
13708
  JsExit = class extends Error {
13547
13709
  status;
13548
13710
  constructor(status2) {