@ai-ecoverse/slicc-kernel 1.26.3 → 1.26.4

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
@@ -6972,6 +6972,7 @@ var WasmProcess = class {
6972
6972
  children;
6973
6973
  caught = 0;
6974
6974
  ignored = 0;
6975
+ inherited = 0;
6975
6976
  interrupt = new AbortController();
6976
6977
  execChild;
6977
6978
  execTermsig;
@@ -6989,12 +6990,19 @@ var WasmProcess = class {
6989
6990
  this.pid = pid;
6990
6991
  this.fds = fds;
6991
6992
  this.options = options;
6993
+ this.inherited = options.ignored ?? 0;
6992
6994
  this.children = new ChildTable(fds, options.spawner, options.forker);
6993
6995
  this.nodes = new VfsNodes(options.fs);
6994
6996
  options.openFiles?.add(this.nodes);
6995
6997
  this.children.onChildState = () => this.signal(SIG.CHLD);
6996
6998
  this.children.onReap = options.onReap;
6997
6999
  }
7000
+ ignores(bit) {
7001
+ return ((this.ignored | this.inherited & ~this.caught) & bit) !== 0;
7002
+ }
7003
+ inheritable(fork = false) {
7004
+ return ((fork ? 0 : this.ignored) | this.inherited) & ~this.caught;
7005
+ }
6998
7006
  signal(sig) {
6999
7007
  if (this.execChild !== void 0) {
7000
7008
  void Promise.resolve(this.options.kill?.(this.execChild, sig)).catch(() => void 0);
@@ -7004,7 +7012,7 @@ var WasmProcess = class {
7004
7012
  if (sig === SIG.CONT) this.cont();
7005
7013
  if (sig === SIG.STOP) return this.stop(sig);
7006
7014
  const bit = sigbit(sig);
7007
- if (this.ignored & bit) return "ignore";
7015
+ if (this.ignores(bit)) return "ignore";
7008
7016
  if (!(this.caught & bit)) {
7009
7017
  const action = defaultAction(sig);
7010
7018
  return action === "stop" ? this.stop(sig) : action;
@@ -7303,7 +7311,7 @@ var WasmProcess = class {
7303
7311
  if (session !== void 0 && session !== tty) return;
7304
7312
  const pgid = this.pgid();
7305
7313
  if (jobs.tcgetpgrp(tty, this.sid()) === pgid) return;
7306
- if (this.ignored & sigbit(SIG.TTIN)) throw new KernelError("EIO");
7314
+ if (this.ignores(sigbit(SIG.TTIN))) throw new KernelError("EIO");
7307
7315
  jobs.killGroup(pgid, SIG.TTIN);
7308
7316
  throw new KernelError("EINTR");
7309
7317
  }
@@ -7531,6 +7539,7 @@ function spawnWasmProcess(opts) {
7531
7539
  const sab = new SharedArrayBuffer(SAB_HEADER_BYTES + SAB_DEFAULT_WINDOW_BYTES);
7532
7540
  const header3 = new Int32Array(sab, 0, SAB_HEADER_I32);
7533
7541
  const process = new WasmProcess(opts.pid, opts.fds, {
7542
+ ...opts.ignored ? { ignored: opts.ignored } : {},
7534
7543
  spawner: opts.spawner,
7535
7544
  forker: opts.forker,
7536
7545
  fs: opts.fs,
@@ -7673,7 +7682,8 @@ function spawnWasmProcess(opts) {
7673
7682
  signal,
7674
7683
  termsig: () => endedBy,
7675
7684
  onState: (listener) => process.onState(listener),
7676
- memory: () => Atomics.load(header3, SAB_I_MEMORY) * 65536
7685
+ memory: () => Atomics.load(header3, SAB_I_MEMORY) * 65536,
7686
+ ignoredSignals: (fork) => process.inheritable(fork)
7677
7687
  };
7678
7688
  }
7679
7689
 
@@ -9294,6 +9304,7 @@ var Launcher = class {
9294
9304
  const terminal = req.fds.stdioTerminal();
9295
9305
  const handle = spawnWasmProcess({
9296
9306
  pid,
9307
+ ...req.ignored ? { ignored: req.ignored } : {},
9297
9308
  program: req.program,
9298
9309
  argv0: req.argv0,
9299
9310
  args: req.args,
@@ -9398,6 +9409,7 @@ var Launcher = class {
9398
9409
  fds,
9399
9410
  report,
9400
9411
  ppid,
9412
+ ignored: this.ignoredBy(ppid),
9401
9413
  ...exec
9402
9414
  });
9403
9415
  return childHandle(handle);
@@ -9405,7 +9417,19 @@ var Launcher = class {
9405
9417
  }
9406
9418
  forker(ppid, parent) {
9407
9419
  const { exec: _exec, ...image } = parent;
9408
- return async (state, fds) => childHandle(this.start({ ...image, cwd: state.cwd ?? parent.cwd, fds, ppid, fork: state }));
9420
+ return async (state, fds) => childHandle(
9421
+ this.start({
9422
+ ...image,
9423
+ cwd: state.cwd ?? parent.cwd,
9424
+ fds,
9425
+ ppid,
9426
+ fork: state,
9427
+ ignored: this.ignoredBy(ppid, true)
9428
+ })
9429
+ );
9430
+ }
9431
+ ignoredBy(pid, fork = false) {
9432
+ return this.processes.get(pid)?.ignoredSignals(fork) ?? 0;
9409
9433
  }
9410
9434
  kill(pid, sig) {
9411
9435
  if (pid < 0) return this.jobs.killGroup(-pid, sig);