@ai-ecoverse/slicc-kernel 1.87.0 → 1.88.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.
@@ -830,9 +830,9 @@ var init_wasi_files = __esm({
830
830
  readable;
831
831
  writable;
832
832
  append;
833
- constructor(buffer, readable2, writable2, append) {
833
+ constructor(buffer, readable3, writable2, append) {
834
834
  this.buffer = buffer;
835
- this.readable = readable2;
835
+ this.readable = readable3;
836
836
  this.writable = writable2;
837
837
  this.append = append;
838
838
  }
@@ -1015,6 +1015,7 @@ var init_wasi_threads = __esm({
1015
1015
  beforeSpawn;
1016
1016
  modules;
1017
1017
  received;
1018
+ blocked;
1018
1019
  port;
1019
1020
  memory;
1020
1021
  cap;
@@ -1035,6 +1036,7 @@ var init_wasi_threads = __esm({
1035
1036
  this.beforeSpawn?.();
1036
1037
  const tid = Atomics.add(this.ids, LAST_TID, 1) + 1;
1037
1038
  const modules = this.modules?.();
1039
+ const blocked = this.blocked?.() ?? 0;
1038
1040
  this.port.postMessage({
1039
1041
  type: WASM_THREAD_SPAWN,
1040
1042
  thread: {
@@ -1042,7 +1044,8 @@ var init_wasi_threads = __esm({
1042
1044
  arg,
1043
1045
  memory: this.memory,
1044
1046
  ids: this.ids.buffer,
1045
- ...modules ? { modules } : {}
1047
+ ...modules ? { modules } : {},
1048
+ ...blocked ? { blocked } : {}
1046
1049
  }
1047
1050
  });
1048
1051
  return tid;
@@ -1160,11 +1163,11 @@ function sabViews(sab) {
1160
1163
  window: new Uint8Array(sab, SAB_HEADER_BYTES)
1161
1164
  };
1162
1165
  }
1163
- 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;
1166
+ 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;
1164
1167
  var init_sync_sab_wire = __esm({
1165
1168
  "src/realm/sync-sab-wire.ts"() {
1166
1169
  "use strict";
1167
- SAB_HEADER_I32 = 16;
1170
+ SAB_HEADER_I32 = 18;
1168
1171
  SAB_CLOCK_OFFSET = SAB_HEADER_I32 * 4;
1169
1172
  SAB_CLOCK_I64 = 3;
1170
1173
  SAB_HEADER_BYTES = SAB_CLOCK_OFFSET + SAB_CLOCK_I64 * 8;
@@ -1184,6 +1187,7 @@ var init_sync_sab_wire = __esm({
1184
1187
  SAB_I_KILLED = 13;
1185
1188
  SAB_I_ASYNC = 14;
1186
1189
  SAB_I_STOP = 15;
1190
+ SAB_I_BLOCKED = 16;
1187
1191
  U32 = 2 ** 32;
1188
1192
  SAB_STATE_IDLE = 0;
1189
1193
  SAB_STATE_PENDING = 1;
@@ -2055,7 +2059,7 @@ var init_wasi_fds = __esm({
2055
2059
  }
2056
2060
  }
2057
2061
  file(path, existing, oflags, rights, fdflags) {
2058
- const { readable: readable2, writable: writable2 } = openAccess(existing, oflags, rights);
2062
+ const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
2059
2063
  let buffer = this.buffers.get(path);
2060
2064
  if (buffer?.handle !== void 0 && this.fs.kept?.(buffer.handle)) {
2061
2065
  this.buffers.delete(path);
@@ -2070,7 +2074,7 @@ var init_wasi_fds = __esm({
2070
2074
  buffer = this.freshBuffer(path, existing, oflags, want);
2071
2075
  }
2072
2076
  buffer.opens++;
2073
- return new LocalFile(buffer, readable2, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
2077
+ return new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
2074
2078
  }
2075
2079
  freshBuffer(path, existing, oflags, want) {
2076
2080
  const made = !existing && this.createNew(path, oflags);
@@ -2089,9 +2093,9 @@ var init_wasi_fds = __esm({
2089
2093
  return buffer;
2090
2094
  }
2091
2095
  kernelFile(path, existing, oflags, rights, fdflags) {
2092
- const { readable: readable2, writable: writable2 } = openAccess(existing, oflags, rights);
2096
+ const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
2093
2097
  const append = (fdflags & FDFLAGS.APPEND) !== 0;
2094
- const flags = (writable2 ? readable2 ? O_RDWR : O_WRONLY : 0) | (append ? O_APPEND : 0);
2098
+ const flags = (writable2 ? readable3 ? O_RDWR : O_WRONLY : 0) | (append ? O_APPEND : 0);
2095
2099
  const made = !existing && this.createNew(path, oflags);
2096
2100
  const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
2097
2101
  const fd = this.kernel.sys.openVfs(path, flags, 0, {
@@ -2492,7 +2496,7 @@ function wrap(table) {
2492
2496
  }
2493
2497
  return out;
2494
2498
  }
2495
- var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SEALED_MODE, WasiHost;
2499
+ var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
2496
2500
  var init_wasi_host = __esm({
2497
2501
  "src/process/wasi/wasi-host.ts"() {
2498
2502
  "use strict";
@@ -2523,6 +2527,7 @@ var init_wasi_host = __esm({
2523
2527
  MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS;
2524
2528
  MAX_READ = 1024 * 1024;
2525
2529
  SIGPIPE_EXIT = 141;
2530
+ SIG_IGN = 1;
2526
2531
  SEALED_MODE = 8630;
2527
2532
  WasiHost = class {
2528
2533
  mem = new WasiMemory();
@@ -2534,6 +2539,7 @@ var init_wasi_host = __esm({
2534
2539
  onRaise;
2535
2540
  muted;
2536
2541
  signals;
2542
+ sigmask;
2537
2543
  interrupted;
2538
2544
  quietly = (fn) => fn();
2539
2545
  listening;
@@ -2725,7 +2731,23 @@ var init_wasi_host = __esm({
2725
2731
  const groups = Array.from({ length: n }, (_, i) => view.getUint32(buf + i * 4, true));
2726
2732
  void this.o.kernel.call({ op: "proc-setcred", change: { groups } });
2727
2733
  },
2728
- sigaction_set: (sig, disposition, flags) => this.signals ? this.signals.disposition(sig, disposition, flags) : E.NOSYS
2734
+ sigaction_set: (sig, disposition, flags) => {
2735
+ if (!this.signals) return E.NOSYS;
2736
+ const errno2 = this.signals.disposition(sig, disposition, flags);
2737
+ if (errno2 === E.SUCCESS && disposition === SIG_IGN) this.sigmask?.discard(sig);
2738
+ return errno2;
2739
+ },
2740
+ sigmask_set: (how, lo, hi, old) => this.sigmask ? this.sigmask.set(how, lo, hi, (oldLo, oldHi) => {
2741
+ if (old === 0) return;
2742
+ const view = mem.view();
2743
+ view.setUint32(old, oldLo, true);
2744
+ view.setUint32(old + 4, oldHi, true);
2745
+ }) : E.NOSYS,
2746
+ sigpending_get: (out) => {
2747
+ if (!this.sigmask) return E.NOSYS;
2748
+ mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
2749
+ return E.SUCCESS;
2750
+ }
2729
2751
  });
2730
2752
  }
2731
2753
  imports() {
@@ -3819,6 +3841,20 @@ var init_signals = __esm({
3819
3841
  }
3820
3842
  });
3821
3843
 
3844
+ // src/version.ts
3845
+ function procVersion() {
3846
+ return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
3847
+ `;
3848
+ }
3849
+ var KERNEL_VERSION, OS_RELEASE;
3850
+ var init_version = __esm({
3851
+ "src/version.ts"() {
3852
+ "use strict";
3853
+ KERNEL_VERSION = true ? "1.88.0" : "0.0.0-dev";
3854
+ OS_RELEASE = "6.0.0-slicc";
3855
+ }
3856
+ });
3857
+
3822
3858
  // src/process/js/js-kernel.ts
3823
3859
  function modeOf(mode) {
3824
3860
  if (!Number.isInteger(mode) || mode < 0 || mode > 4095) {
@@ -4104,6 +4140,7 @@ function childOps(kernel, io, defaults, sync) {
4104
4140
  if (file === void 0) throw new JsCallError("EINVAL", "spawn");
4105
4141
  const group = groupOf(o, "spawn");
4106
4142
  const named = argv0Of(o.argv0, "spawn");
4143
+ const death = deathOf(o.parentDeathSignal, defaults);
4107
4144
  return (stdio) => ({
4108
4145
  op: "proc-spawn",
4109
4146
  file,
@@ -4112,7 +4149,8 @@ function childOps(kernel, io, defaults, sync) {
4112
4149
  env: { ...o.env ?? defaults.env },
4113
4150
  cwd: o.cwd ?? defaults.cwd,
4114
4151
  stdio,
4115
- ...group
4152
+ ...group,
4153
+ ...death
4116
4154
  });
4117
4155
  };
4118
4156
  const spawnSync = (o) => {
@@ -4155,6 +4193,13 @@ function groupOf(o, call2) {
4155
4193
  if (session && pgid !== void 0) throw new JsCallError("EINVAL", call2);
4156
4194
  return session ? { session: true } : pgid !== void 0 ? { pgid } : {};
4157
4195
  }
4196
+ function deathOf(signal, defaults) {
4197
+ if (signal === void 0) return {};
4198
+ if (typeof signal !== "number" && typeof signal !== "string") {
4199
+ throw new JsCallError("EINVAL", "spawn");
4200
+ }
4201
+ return { deathSignal: defaults.signal(signal) };
4202
+ }
4158
4203
  function argv0Of(argv0, call2) {
4159
4204
  if (argv0 === void 0) return {};
4160
4205
  if (typeof argv0 !== "string") throw new JsCallError("EINVAL", call2);
@@ -5114,7 +5159,7 @@ function netOps(kernel, io) {
5114
5159
  return closed;
5115
5160
  };
5116
5161
  const shut = (how) => kernel.raw({ op: "sock-shutdown", fd, how });
5117
- const readable2 = new ReadableStream(
5162
+ const readable3 = new ReadableStream(
5118
5163
  {
5119
5164
  async pull(controller) {
5120
5165
  const chunk = await io.read(fd, void 0, stop.signal);
@@ -5130,7 +5175,7 @@ function netOps(kernel, io) {
5130
5175
  close: async () => void await shut(SHUT_WR),
5131
5176
  abort: () => close()
5132
5177
  });
5133
- return { fd, local: local2, remote, readable: readable2, writable: writable2, close };
5178
+ return { fd, local: local2, remote, readable: readable3, writable: writable2, close };
5134
5179
  };
5135
5180
  const resolve = async (host, signal) => {
5136
5181
  if (IPV4.test(host)) return host;
@@ -5964,7 +6009,7 @@ function websocketOp(kernel) {
5964
6009
  reason: closeReason(how.reason)
5965
6010
  });
5966
6011
  };
5967
- const readable2 = new ReadableStream(
6012
+ const readable3 = new ReadableStream(
5968
6013
  {
5969
6014
  async pull(controller) {
5970
6015
  let r;
@@ -6014,7 +6059,7 @@ function websocketOp(kernel) {
6014
6059
  close: () => close(),
6015
6060
  abort: () => close({ code: 1e3, reason: "" })
6016
6061
  });
6017
- return { url, protocol, readable: readable2, writable: writable2, closed, close };
6062
+ return { url, protocol, readable: readable3, writable: writable2, closed, close };
6018
6063
  };
6019
6064
  }
6020
6065
  var SEND_BUFFER, MAX_REASON, NEVER2, wait;
@@ -6047,9 +6092,11 @@ function signalNumber(signal) {
6047
6092
  if (Number.isInteger(signal) && signal >= 1 && signal <= 31) return signal;
6048
6093
  throw new JsCallError("EINVAL", `signal ${signal}`);
6049
6094
  }
6050
- const n = SIG[signal.slice(3)];
6051
- if (n === void 0) throw new JsCallError("EINVAL", `signal ${signal}`);
6052
- return n;
6095
+ const name2 = signal.slice(3);
6096
+ if (!signal.startsWith("SIG") || !Object.hasOwn(SIG, name2)) {
6097
+ throw new JsCallError("EINVAL", `signal ${signal}`);
6098
+ }
6099
+ return SIG[name2];
6053
6100
  }
6054
6101
  function resolvePath(cwd, path) {
6055
6102
  const parts = [];
@@ -6119,6 +6166,18 @@ function writer(kernel, info, pid) {
6119
6166
  };
6120
6167
  return { writes, writeAll };
6121
6168
  }
6169
+ function readable2(read2) {
6170
+ return new ReadableStream(
6171
+ {
6172
+ async pull(controller) {
6173
+ const chunk = await read2(0);
6174
+ if (chunk.length === 0) controller.close();
6175
+ else controller.enqueue(chunk);
6176
+ }
6177
+ },
6178
+ { highWaterMark: 0 }
6179
+ );
6180
+ }
6122
6181
  function createContext(o) {
6123
6182
  const { kernel } = o;
6124
6183
  const infos = /* @__PURE__ */ new Map();
@@ -6199,6 +6258,7 @@ function createContext(o) {
6199
6258
  const syncKernel = new JsSyncKernel(lane, kernel, unwind);
6200
6259
  const terminal = ttyOps(kernel);
6201
6260
  const sync = {
6261
+ kernel: KERNEL_INFO,
6202
6262
  ...syncOps(syncKernel, { pid: o.pid, resolve, random, infos, handles }),
6203
6263
  run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
6204
6264
  spawn: (options) => spawnSync(options),
@@ -6220,6 +6280,7 @@ function createContext(o) {
6220
6280
  const { spawnSync, ...children } = childOps(kernel, io, defaults, syncKernel);
6221
6281
  const strays = o.strays ?? { exception: /* @__PURE__ */ new Set(), rejection: /* @__PURE__ */ new Set() };
6222
6282
  const ctx = {
6283
+ kernel: KERNEL_INFO,
6223
6284
  argv: o.argv,
6224
6285
  env: o.env,
6225
6286
  pid: o.pid,
@@ -6227,16 +6288,7 @@ function createContext(o) {
6227
6288
  return identityOf(await kernel.json({ op: "proc-identity" }), o).ppid;
6228
6289
  },
6229
6290
  cwd: o.cwd,
6230
- stdin: new ReadableStream(
6231
- {
6232
- async pull(controller) {
6233
- const chunk = await read2(0);
6234
- if (chunk.length === 0) controller.close();
6235
- else controller.enqueue(chunk);
6236
- }
6237
- },
6238
- { highWaterMark: 0 }
6239
- ),
6291
+ stdin: readable2(read2),
6240
6292
  stdout: writable2(1),
6241
6293
  stderr: writable2(2),
6242
6294
  read: read2,
@@ -6445,12 +6497,13 @@ function pathOps(kernel, resolve, statOf, open) {
6445
6497
  }
6446
6498
  };
6447
6499
  }
6448
- var JsExit, encoder4;
6500
+ var KERNEL_INFO, JsExit, encoder4;
6449
6501
  var init_js_context = __esm({
6450
6502
  "src/process/js/js-context.ts"() {
6451
6503
  "use strict";
6452
6504
  init_signals();
6453
6505
  init_sync_fs_wire();
6506
+ init_version();
6454
6507
  init_js_children();
6455
6508
  init_js_dev();
6456
6509
  init_js_exit();
@@ -6462,6 +6515,7 @@ var init_js_context = __esm({
6462
6515
  init_js_sync();
6463
6516
  init_js_tty();
6464
6517
  init_js_websocket();
6518
+ KERNEL_INFO = Object.freeze({ version: KERNEL_VERSION });
6465
6519
  JsExit = class extends Error {
6466
6520
  status;
6467
6521
  constructor(status2) {
@@ -9498,7 +9552,7 @@ var init_process_signals = __esm({
9498
9552
  interrupt() {
9499
9553
  this.report();
9500
9554
  const header = this.header;
9501
- const pending = Atomics.load(header, SAB_I_SIGNALS) | Atomics.load(header, SAB_I_TIMERS) | Atomics.load(header, SAB_I_KILLED);
9555
+ 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);
9502
9556
  if (pending === 0) return false;
9503
9557
  this.deliver();
9504
9558
  return true;
@@ -9511,7 +9565,8 @@ var init_process_signals = __esm({
9511
9565
  this.hooks.killed(killed);
9512
9566
  }
9513
9567
  const timers = Atomics.exchange(this.header, SAB_I_TIMERS, 0);
9514
- const pending = Atomics.exchange(this.header, SAB_I_SIGNALS, 0);
9568
+ const blocked = Atomics.load(this.header, SAB_I_BLOCKED);
9569
+ const pending = blocked === 0 ? Atomics.exchange(this.header, SAB_I_SIGNALS, 0) : Atomics.and(this.header, SAB_I_SIGNALS, blocked) & ~blocked;
9515
9570
  if (this.depth <= 1) this.lastDelivered = pending | (timers & 1 ? sigbit(SIG.ALRM) : 0);
9516
9571
  if (pending !== 0 || timers !== 0) this.delivered++;
9517
9572
  for (let which = 0; which < 3; which++) {
@@ -9689,6 +9744,14 @@ var init_process_sockets = __esm({
9689
9744
  });
9690
9745
 
9691
9746
  // src/process/procfs.ts
9747
+ function sysEntry(parts) {
9748
+ let at = SYS_TREE;
9749
+ for (const part of parts) {
9750
+ if (typeof at !== "object" || !Object.hasOwn(at, part)) return void 0;
9751
+ at = at[part];
9752
+ }
9753
+ return at;
9754
+ }
9692
9755
  function commOf(info) {
9693
9756
  const name2 = info.argv[0] ?? "";
9694
9757
  return name2.slice(name2.lastIndexOf("/") + 1).slice(0, 15);
@@ -9773,7 +9836,7 @@ function pidStatus(info) {
9773
9836
  "SigQ: 0/0",
9774
9837
  "SigPnd: 0000000000000000",
9775
9838
  "ShdPnd: 0000000000000000",
9776
- "SigBlk: 0000000000000000",
9839
+ `SigBlk: ${sigMask(info.sigBlk)}`,
9777
9840
  `SigIgn: ${sigMask(info.sigIgn)}`,
9778
9841
  `SigCgt: ${sigMask(info.sigCgt)}`,
9779
9842
  ""
@@ -9809,6 +9872,7 @@ function memoryInfo(source, used = 0) {
9809
9872
  ].map(([key, value2]) => `${`${key}:`.padEnd(16)}${value2.padStart(12)}`).concat("").join("\n");
9810
9873
  }
9811
9874
  function systemFile(name2, listing, now, memory) {
9875
+ if (name2 === "version") return procVersion();
9812
9876
  const up = Math.max(0, now - listing.boot) / 1e3;
9813
9877
  if (name2 === "uptime") return `${up.toFixed(2)} ${up.toFixed(2)}
9814
9878
  `;
@@ -9925,6 +9989,16 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
9925
9989
  if (!info) throw error();
9926
9990
  return pidFile(name2, info, listing.boot);
9927
9991
  };
9992
+ const sysDir = (parent, name2, tree) => {
9993
+ const dir = fresh(parent, name2, DIR_MODE2);
9994
+ dir.node_ops.lookup = (at, child) => {
9995
+ if (!Object.hasOwn(tree, child)) throw error();
9996
+ const next2 = tree[child];
9997
+ return typeof next2 === "string" ? file(at, child, () => next2) : sysDir(at, child, next2);
9998
+ };
9999
+ dir.node_ops.readdir = () => [".", "..", ...Object.keys(tree)];
10000
+ return dir;
10001
+ };
9928
10002
  const pidNames = (names) => [.../* @__PURE__ */ new Set([...names, ...PID_FILES])];
9929
10003
  const pidDir = (name2, target) => {
9930
10004
  const dir = fresh(proc, name2, DIR_MODE2);
@@ -9949,7 +10023,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
9949
10023
  const readdir = procOps.readdir?.bind(procOps);
9950
10024
  const listAll = (node) => {
9951
10025
  const names = new Set(readdir ? readdir(node) : [".", ".."]);
9952
- for (const name2 of [...SYSTEM_FILES, "mounts"]) names.add(name2);
10026
+ for (const name2 of [...SYSTEM_FILES, "mounts", "sys"]) names.add(name2);
9953
10027
  for (const p of procList().processes) names.add(String(p.pid));
9954
10028
  return [...names];
9955
10029
  };
@@ -9961,6 +10035,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
9961
10035
  return pidDir(name2, Number(name2));
9962
10036
  }
9963
10037
  if (name2 === "mounts") return file(parent, name2, () => mountTable(sys.mountList?.() ?? []));
10038
+ if (name2 === "sys") return sysDir(parent, name2, SYS_TREE);
9964
10039
  if (SYSTEM_FILES.includes(name2)) {
9965
10040
  return file(
9966
10041
  parent,
@@ -10024,11 +10099,12 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
10024
10099
  readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
10025
10100
  };
10026
10101
  }
10027
- var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID2, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask, STATES, tagLine;
10102
+ var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID2, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, SYS_TREE, sigMask, STATES, tagLine;
10028
10103
  var init_procfs = __esm({
10029
10104
  "src/process/procfs.ts"() {
10030
10105
  "use strict";
10031
10106
  init_cred();
10107
+ init_version();
10032
10108
  init_process_fds();
10033
10109
  HZ = 100;
10034
10110
  DIR_MODE2 = 16749;
@@ -10040,7 +10116,11 @@ var init_procfs = __esm({
10040
10116
  KIB = 1024;
10041
10117
  FALLBACK_MEMORY = 4 * KIB * KIB * KIB;
10042
10118
  PID_FILES = ["cmdline", "comm", "stat", "statm", "status"];
10043
- SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime"];
10119
+ SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime", "version"];
10120
+ SYS_TREE = {
10121
+ kernel: { osrelease: `${OS_RELEASE}
10122
+ `, ostype: "Linux\n" }
10123
+ };
10044
10124
  sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
10045
10125
  STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
10046
10126
  tagLine = (tag) => `Tag: ${tag.replaceAll("\n", "\\n").replaceAll(" ", "\\t").replaceAll("\r", "\\r")}`;
@@ -11014,11 +11094,17 @@ var init_wasi_procfs = __esm({
11014
11094
  names: () => [
11015
11095
  ...SYSTEM_NAMES,
11016
11096
  "mounts",
11097
+ "sys",
11017
11098
  "self",
11018
11099
  ...this.listing().processes.map((p) => String(p.pid))
11019
11100
  ]
11020
11101
  };
11021
11102
  }
11103
+ if (top === "sys") {
11104
+ const entry = sysEntry(parts.slice(1));
11105
+ if (typeof entry === "string") return { kind: "file", content: () => entry };
11106
+ return entry && { kind: "dir", names: () => Object.keys(entry) };
11107
+ }
11022
11108
  if (top === "self") {
11023
11109
  return leaf === void 0 ? { kind: "link", target: String(this.pid) } : void 0;
11024
11110
  }
@@ -11102,6 +11188,63 @@ var init_wasi_procfs = __esm({
11102
11188
  }
11103
11189
  });
11104
11190
 
11191
+ // src/process/wasi/wasi-sigmask.ts
11192
+ var UNBLOCKABLE, LIBC_UNBLOCKABLE, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
11193
+ var init_wasi_sigmask = __esm({
11194
+ "src/process/wasi/wasi-sigmask.ts"() {
11195
+ "use strict";
11196
+ init_signals();
11197
+ init_sync_sab_wire();
11198
+ init_wasi_abi();
11199
+ UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
11200
+ LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
11201
+ SIG_BLOCK = 0;
11202
+ SIG_UNBLOCK = 1;
11203
+ SIG_SETMASK = 2;
11204
+ kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
11205
+ libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
11206
+ apply = (how, mask, set) => {
11207
+ if (how === SIG_BLOCK) return mask | set;
11208
+ if (how === SIG_UNBLOCK) return mask & ~set;
11209
+ return set;
11210
+ };
11211
+ WasiSigmask = class {
11212
+ lo;
11213
+ hi = 0;
11214
+ header;
11215
+ deliver;
11216
+ process;
11217
+ constructor(header, deliver, process) {
11218
+ this.header = header;
11219
+ this.deliver = deliver;
11220
+ this.process = process;
11221
+ this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
11222
+ }
11223
+ static unsupported(header) {
11224
+ Atomics.store(header, SAB_I_BLOCKED, 0);
11225
+ }
11226
+ set(how, setLo, setHi, old) {
11227
+ if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
11228
+ old(this.lo >>> 0, this.hi >>> 0);
11229
+ this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
11230
+ this.hi = apply(how, this.hi, setHi | 0);
11231
+ const now = kernelBits(this.lo);
11232
+ Atomics.store(this.header, SAB_I_BLOCKED, now);
11233
+ if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
11234
+ return E.SUCCESS;
11235
+ }
11236
+ discard(sig) {
11237
+ Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
11238
+ if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
11239
+ }
11240
+ pending() {
11241
+ const own = Atomics.load(this.header, SAB_I_SIGNALS);
11242
+ return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
11243
+ }
11244
+ };
11245
+ }
11246
+ });
11247
+
11105
11248
  // src/process/wasi/wasi-signals.ts
11106
11249
  var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
11107
11250
  var init_wasi_signals = __esm({
@@ -11187,7 +11330,11 @@ var init_wasi_signals = __esm({
11187
11330
  }
11188
11331
  raise(sig) {
11189
11332
  const handler = this.handler();
11190
- if (!handler) return;
11333
+ if (!handler && !this.hooked) return;
11334
+ if (!handler || this.hooked && (this.handlers & sigbit(sig)) === 0) {
11335
+ if ((this.ignoring & sigbit(sig)) === 0) this.defaultAction(sig);
11336
+ return;
11337
+ }
11191
11338
  const outer = { sig: this.delivering, defaulted: this.defaulted, libc: this.libcDefault };
11192
11339
  this.delivering = sig;
11193
11340
  this.defaulted = false;
@@ -13064,6 +13211,7 @@ __export(wasi_runtime_exports, {
13064
13211
  delivering: () => delivering,
13065
13212
  runWasiProcess: () => runWasiProcess,
13066
13213
  runWasiThread: () => runWasiThread,
13214
+ sigmaskOf: () => sigmaskOf,
13067
13215
  trapMessage: () => trapMessage,
13068
13216
  unsupportedImport: () => unsupportedImport,
13069
13217
  wireSignals: () => wireSignals
@@ -13100,6 +13248,16 @@ function delivering(ns, table, host, driver, before) {
13100
13248
  }
13101
13249
  return out;
13102
13250
  }
13251
+ function sigmaskOf(module, sab, gate, threads, process) {
13252
+ const header = new Int32Array(sab, 0, SAB_HEADER_I32);
13253
+ if (!importsSlicc(module, "sigmask_set")) {
13254
+ WasiSigmask.unsupported(header);
13255
+ return void 0;
13256
+ }
13257
+ if (threads) threads.blocked = () => Atomics.load(header, SAB_I_BLOCKED);
13258
+ const shared = process && new Int32Array(process, 0, SAB_HEADER_I32);
13259
+ return new WasiSigmask(header, () => gate.deliver(), shared);
13260
+ }
13103
13261
  function enosys(module, name2, foreign) {
13104
13262
  const type = foreign?.[module]?.[name2];
13105
13263
  if (type === "other") throw new Error(noErrno(`${module}.${name2}`));
@@ -13413,6 +13571,7 @@ async function runWasiProcess(init, port3) {
13413
13571
  ),
13414
13572
  ...descriptors(init, fork, threads)
13415
13573
  });
13574
+ host.sigmask = sigmaskOf(module, init.sab, gate, threads);
13416
13575
  if (threads) {
13417
13576
  threads.beforeSpawn = () => {
13418
13577
  if (!host.fds.isShared) host.fds.share(threads.ids, false);
@@ -13507,6 +13666,7 @@ async function runWasiThread(init, port3) {
13507
13666
  ),
13508
13667
  shared: threads.ids
13509
13668
  });
13669
+ host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
13510
13670
  const program = await programImports(init.program, host, transport, thread.tid);
13511
13671
  const { instance } = await instantiate(host, init.program.module, thread.memory, threads, {
13512
13672
  thread: true,
@@ -13542,7 +13702,7 @@ async function runWasiThread(init, port3) {
13542
13702
  throw e;
13543
13703
  }
13544
13704
  }
13545
- 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;
13705
+ 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;
13546
13706
  var init_wasi_runtime = __esm({
13547
13707
  "src/process/wasi/wasi-runtime.ts"() {
13548
13708
  "use strict";
@@ -13560,6 +13720,7 @@ var init_wasi_runtime = __esm({
13560
13720
  init_wasi_imports();
13561
13721
  init_wasi_module();
13562
13722
  init_wasi_procfs();
13723
+ init_wasi_sigmask();
13563
13724
  init_wasi_signals();
13564
13725
  init_wasi_stats();
13565
13726
  init_wasi_threads();
@@ -13586,7 +13747,8 @@ var init_wasi_runtime = __esm({
13586
13747
  wasi: ["thread-spawn"]
13587
13748
  };
13588
13749
  DELIVERED = [PREVIEW1, WASIX, SLICC, SLICC_FS, SLICC_TTY];
13589
- importsSigactionHook = (module) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === "sigaction_set");
13750
+ importsSlicc = (module, name2) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === name2);
13751
+ importsSigactionHook = (module) => importsSlicc(module, "sigaction_set");
13590
13752
  noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
13591
13753
  FALLBACK_MAXIMUM_PAGES = 32768;
13592
13754
  LinkSync = class {