@ai-ecoverse/slicc-kernel 1.100.3 → 1.101.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.
package/dist/node.js CHANGED
@@ -11107,7 +11107,7 @@ var PATH_OPS = new Set(SYNC_FS_OPS);
11107
11107
  var EARLY_WHOLE_FILE = 64 * 1024;
11108
11108
 
11109
11109
  // src/version.ts
11110
- var KERNEL_VERSION = true ? "1.100.3" : "0.0.0-dev";
11110
+ var KERNEL_VERSION = true ? "1.101.0" : "0.0.0-dev";
11111
11111
  var OS_RELEASE = "6.0.0-slicc";
11112
11112
  function procVersion() {
11113
11113
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13674,6 +13674,7 @@ var KernelTty = class {
13674
13674
  this.wake();
13675
13675
  }
13676
13676
  resize(cols, rows) {
13677
+ if (cols === this.cols && rows === this.rows) return;
13677
13678
  this.setSize(cols, rows);
13678
13679
  this.signal(SIG.WINCH);
13679
13680
  }
@@ -14048,6 +14049,9 @@ function terminalOf(ctx, fd) {
14048
14049
  }
14049
14050
  var json4 = (value) => ({ ok: true, kind: "json", json: value });
14050
14051
  var done3 = { ok: true, kind: "void" };
14052
+ function sizeKey(rows, cols) {
14053
+ return `${rows}x${cols}`;
14054
+ }
14051
14055
  function ptySyscall(req, ctx) {
14052
14056
  switch (req.op) {
14053
14057
  case "pty-open": {
@@ -14080,9 +14084,11 @@ function ptySyscall(req, ctx) {
14080
14084
  case "pty-packet":
14081
14085
  masterOf(ctx, req.fd).packet = req.on;
14082
14086
  return done3;
14083
- case "pty-winsz-set":
14084
- terminalOf(ctx, req.fd).resize(req.cols, req.rows);
14087
+ case "pty-winsz-set": {
14088
+ const tty = terminalOf(ctx, req.fd);
14089
+ if (ctx.sizesRead?.get(tty) !== sizeKey(req.rows, req.cols)) tty.resize(req.cols, req.rows);
14085
14090
  return done3;
14091
+ }
14086
14092
  }
14087
14093
  }
14088
14094
 
@@ -14246,13 +14252,6 @@ var SEM_NAMES_MAX = 4096;
14246
14252
  var SEM_HANDLES_MAX = 256;
14247
14253
  var NAME_MAX = 251;
14248
14254
  var TIMER_MAX_MS = 2147483647;
14249
- var deadlines = /* @__PURE__ */ new WeakMap();
14250
- function timeLeft(req, timeoutMs) {
14251
- const now = performance.now();
14252
- const deadline = deadlines.get(req) ?? now + timeoutMs;
14253
- deadlines.set(req, deadline);
14254
- return Math.max(0, deadline - now);
14255
- }
14256
14255
  var SEM_OPS = [
14257
14256
  "sem-open",
14258
14257
  "sem-close",
@@ -14439,9 +14438,8 @@ async function semSyscall(req, proc) {
14439
14438
  const sem = handles.get(req.handle);
14440
14439
  if (sem.take()) return ok2();
14441
14440
  if (req.how === "try") throw new KernelError("EAGAIN");
14442
- const timeoutMs = req.how === "block" ? -1 : timeLeft(req, req.timeoutMs);
14443
- if (timeoutMs === 0) throw new KernelError("ETIMEDOUT");
14444
- const got = await sem.wait(proc.blocking(), timeoutMs);
14441
+ if (req.how === "timed" && req.timeoutMs === 0) throw new KernelError("ETIMEDOUT");
14442
+ const got = await sem.wait(proc.blocking(), req.how === "block" ? -1 : req.timeoutMs);
14445
14443
  if (!got) throw new KernelError("ETIMEDOUT");
14446
14444
  return ok2();
14447
14445
  }
@@ -15464,7 +15462,7 @@ function identityKey(st, path) {
15464
15462
  }
15465
15463
  var DYING = { ok: false, errno: "EINTR", message: "the process is being killed" };
15466
15464
  var HOSTS_ONLY = new Resolver({ routes: new Routes() });
15467
- function timeLeft2(req, started) {
15465
+ function timeLeft(req, started) {
15468
15466
  if (!("timeoutMs" in req) || typeof req.timeoutMs !== "number" || req.timeoutMs < 0) return req;
15469
15467
  return { ...req, timeoutMs: Math.max(0, req.timeoutMs - (performance.now() - started)) };
15470
15468
  }
@@ -15626,6 +15624,7 @@ var WasmProcess = class {
15626
15624
  for (const listener of this.stateListeners) listener("continued", SIG.CONT);
15627
15625
  }
15628
15626
  blocks = /* @__PURE__ */ new WeakMap();
15627
+ sizesRead = /* @__PURE__ */ new WeakMap();
15629
15628
  async syscall(req, cancelled, block) {
15630
15629
  this.options.onSyscall?.(req);
15631
15630
  const started = performance.now();
@@ -15633,7 +15632,7 @@ var WasmProcess = class {
15633
15632
  for (; ; ) {
15634
15633
  await this.resumed;
15635
15634
  if (this.dying) return DYING;
15636
- const current = restarted ? timeLeft2(req, started) : req;
15635
+ const current = restarted ? timeLeft(req, started) : req;
15637
15636
  const stops = this.stops;
15638
15637
  const scope = new AbortController();
15639
15638
  const forward = () => scope.abort();
@@ -15696,7 +15695,17 @@ var WasmProcess = class {
15696
15695
  const owner = this.options.owners ? this.ttyOwner() : void 0;
15697
15696
  const guard2 = this.guarded();
15698
15697
  const { outputFilter } = this.options;
15699
- const ctx = { pid: this.pid, fds: this.fds, ptys, jobs, guard: guard2, owner, outputFilter };
15698
+ const sizesRead = this.sizesRead;
15699
+ const ctx = {
15700
+ pid: this.pid,
15701
+ fds: this.fds,
15702
+ ptys,
15703
+ jobs,
15704
+ guard: guard2,
15705
+ owner,
15706
+ outputFilter,
15707
+ sizesRead
15708
+ };
15700
15709
  return ptySyscall(req, ctx);
15701
15710
  }
15702
15711
  return await this.procSyscall(req, cancelled);
@@ -16332,8 +16341,11 @@ var WasmProcess = class {
16332
16341
  case "tty-set":
16333
16342
  tty.tcsets(req.termios, req.flush === true);
16334
16343
  return { ok: true, kind: "void" };
16335
- case "tty-winsz":
16336
- return { ok: true, kind: "json", json: tty.winsize() };
16344
+ case "tty-winsz": {
16345
+ const size = tty.winsize();
16346
+ this.sizesRead.set(tty, sizeKey(...size));
16347
+ return { ok: true, kind: "json", json: size };
16348
+ }
16337
16349
  case "tty-pgrp-get":
16338
16350
  return { ok: true, kind: "json", json: jobs ? jobs.tcgetpgrp(tty, this.sid()) : this.pid };
16339
16351
  case "tty-pgrp-set":