@ai-ecoverse/slicc-kernel 1.54.6 → 1.54.8

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
@@ -947,9 +947,9 @@ var KernelSocket = class _KernelSocket {
947
947
  case SO_TYPE:
948
948
  return SOCK_STREAM;
949
949
  case SO_ERROR: {
950
- const failed = this.failed;
950
+ const failed2 = this.failed;
951
951
  this.failed = void 0;
952
- return failed ? wasiErrno(failed) : 0;
952
+ return failed2 ? wasiErrno(failed2) : 0;
953
953
  }
954
954
  case SO_ACCEPTCONN:
955
955
  return this.state === "listening" ? 1 : 0;
@@ -6456,6 +6456,7 @@ function* procWalk(path, follow2) {
6456
6456
  let done4 = [];
6457
6457
  let todo = path.split("/").filter((part) => part !== "");
6458
6458
  let hops = 0;
6459
+ let broken;
6459
6460
  while (todo.length > 0) {
6460
6461
  const part = todo.shift();
6461
6462
  if (part === ".") continue;
@@ -6465,19 +6466,31 @@ function* procWalk(path, follow2) {
6465
6466
  }
6466
6467
  const at = `/${[...done4, part].join("/")}`;
6467
6468
  const whole = normalize(`/${[...done4, part, ...todo].join("/")}`);
6468
- if (inProc(at) && inProc(whole)) return whole;
6469
+ if (inProc(at) && inProc(whole)) return broken ?? whole;
6469
6470
  if (!follow2 && todo.length === 0) return void 0;
6470
- const target = yield at;
6471
- if (target === null) return void 0;
6472
- if (target === void 0) done4.push(part);
6473
- else {
6471
+ const target = yield { at, check: todo.find((next2) => next2 !== ".") === ".." };
6472
+ if (typeof target === "string") {
6474
6473
  if (++hops > MAX_HOPS2) return void 0;
6475
- if (target.startsWith("/")) done4 = [];
6476
- todo = [...target.split("/").filter((part2) => part2 !== ""), ...todo];
6474
+ [done4, todo] = throughLink(target, done4, todo);
6475
+ } else {
6476
+ broken ??= refusalOf(target);
6477
+ done4.push(part);
6477
6478
  }
6478
6479
  }
6479
6480
  return void 0;
6480
6481
  }
6482
+ function failed(err) {
6483
+ const code = err?.code;
6484
+ return { refused: typeof code === "string" ? code : "ENOENT" };
6485
+ }
6486
+ function refusalOf(found) {
6487
+ if (found === true) return void 0;
6488
+ return found === false ? { refused: "ENOTDIR" } : found;
6489
+ }
6490
+ function throughLink(target, done4, todo) {
6491
+ const parts = target.split("/").filter((part) => part !== "");
6492
+ return [target.startsWith("/") ? [] : done4, [...parts, ...todo]];
6493
+ }
6481
6494
  async function procAlias(fs, path, follow2) {
6482
6495
  const { readlink, lstat } = fs;
6483
6496
  if (!readlink || !lstat) return void 0;
@@ -6489,7 +6502,10 @@ async function procAlias(fs, path, follow2) {
6489
6502
  const walk = procWalk(path, follow2);
6490
6503
  let step = walk.next();
6491
6504
  while (!step.done) {
6492
- const target = await readlink.call(fs, step.value).catch(() => void 0);
6505
+ const { at, check } = step.value;
6506
+ const link2 = await readlink.call(fs, at).catch(() => void 0);
6507
+ const isDir = (st) => st.isDirectory === true;
6508
+ const target = link2 ?? (check ? await lstat.call(fs, at).then(isDir, failed) : true);
6493
6509
  step = walk.next(target);
6494
6510
  }
6495
6511
  return step.value;
@@ -9856,6 +9872,8 @@ var WasmProcess = class {
9856
9872
  async openVfs(req) {
9857
9873
  if (inProc(req.path)) return this.openProc(req, req.path);
9858
9874
  const alias = req.orphan ? void 0 : await procAlias(this.options.fs, req.path, !req.exclusive);
9875
+ if (typeof alias === "object")
9876
+ throw Object.assign(new Error(alias.refused), { code: alias.refused });
9859
9877
  if (alias !== void 0) return this.openProc(req, alias);
9860
9878
  await refuseReadonly(this.options.fs, req.path, req.flags, req);
9861
9879
  const fd = this.fds.install(heldFile(), 3);
@@ -11512,22 +11530,22 @@ async function mountFstab(lines2, mount, signal, retries = FSTAB_RETRIES, discar
11512
11530
  );
11513
11531
  }
11514
11532
  async function mountLine({ line, spec, invalid }, mount, signal, retries, discard) {
11515
- let failed = invalid;
11533
+ let failed2 = invalid;
11516
11534
  for (let attempt = 0; !invalid && attempt <= retries.length && !signal.aborted; attempt++) {
11517
11535
  try {
11518
11536
  const entry = await mount(spec);
11519
11537
  if (!signal.aborted) return { line, target: spec.target, entry };
11520
11538
  discard(entry);
11521
- failed = Object.assign(new Error("the kernel stopped"), { code: "ECANCELED" });
11539
+ failed2 = Object.assign(new Error("the kernel stopped"), { code: "ECANCELED" });
11522
11540
  break;
11523
11541
  } catch (err) {
11524
- failed = err;
11542
+ failed2 = err;
11525
11543
  if (FINAL.has(codeOf3(err)) || attempt === retries.length) break;
11526
11544
  await wait(retries[attempt], signal);
11527
11545
  }
11528
11546
  }
11529
- const code = codeOf3(failed);
11530
- return { line, target: spec.target, code, error: String(failed?.message ?? code) };
11547
+ const code = codeOf3(failed2);
11548
+ return { line, target: spec.target, code, error: String(failed2?.message ?? code) };
11531
11549
  }
11532
11550
 
11533
11551
  // src/mount/hostfs.ts
@@ -12906,7 +12924,7 @@ var Launcher = class {
12906
12924
  this.processes.set(pid, handle);
12907
12925
  const { cred } = req;
12908
12926
  this.creds.set(pid, () => handle.cred?.() ?? copyCred(cred));
12909
- if (req.ppid !== void 0) this.settling.started(pid, req.ppid);
12927
+ if (req.ppid !== void 0 && this.controlsJobs(req.ppid)) this.settling.started(pid, req.ppid);
12910
12928
  this.jobs.add(pid, req.ppid, (sig) => handle.signal(sig), terminal);
12911
12929
  if (req.exec && req.ppid !== void 0) this.jobs.exec(req.ppid, pid, true);
12912
12930
  if (req.pgid !== void 0) this.jobs.join(pid, req.pgid);
@@ -13076,6 +13094,9 @@ var Launcher = class {
13076
13094
  const masks = this.processes.get(pid)?.signalMasks?.();
13077
13095
  return masks ? { sigIgn: masks.ignored, sigCgt: masks.caught } : {};
13078
13096
  }
13097
+ controlsJobs(pid) {
13098
+ return this.settling.isSettling(pid) || (this.ignoredBy(pid) & sigbit(SIG.TTOU)) !== 0;
13099
+ }
13079
13100
  ignoredBy(pid, fork = false) {
13080
13101
  return this.processes.get(pid)?.ignoredSignals(fork) ?? 0;
13081
13102
  }