@ai-ecoverse/slicc-kernel 1.47.2 → 1.48.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/README.md +12 -1
- package/dist/kernel-worker.js +32 -3
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +83 -9
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +32 -3
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +83 -9
- package/dist/process-worker.js.map +4 -4
- package/package.json +2 -2
package/dist/node.js
CHANGED
|
@@ -7886,9 +7886,9 @@ var KernelTty = class {
|
|
|
7886
7886
|
this.line = [];
|
|
7887
7887
|
} else if (byte === 10) {
|
|
7888
7888
|
this.line.push(byte);
|
|
7889
|
-
if (echo) this.output(encoder2.encode("\n"));
|
|
7890
7889
|
this.readable.push(Uint8Array.from(this.line));
|
|
7891
7890
|
this.line = [];
|
|
7891
|
+
if (echo) this.output(encoder2.encode("\n"));
|
|
7892
7892
|
} else {
|
|
7893
7893
|
this.line.push(byte);
|
|
7894
7894
|
if (echo) this.echo(byte);
|
|
@@ -9249,6 +9249,7 @@ var WasmProcess = class {
|
|
|
9249
9249
|
}
|
|
9250
9250
|
signal(sig) {
|
|
9251
9251
|
if (this.execChild !== void 0) {
|
|
9252
|
+
if (sig === SIG.CONT) this.cont();
|
|
9252
9253
|
void Promise.resolve(this.options.kill?.(this.execChild, sig)).catch(() => void 0);
|
|
9253
9254
|
if (sig !== SIG.KILL) return "forward";
|
|
9254
9255
|
if (!this.options.writesBack?.(this.execChild)) return "terminate";
|
|
@@ -9629,7 +9630,7 @@ var WasmProcess = class {
|
|
|
9629
9630
|
case "tty-pgrp-get":
|
|
9630
9631
|
return { ok: true, kind: "json", json: jobs ? jobs.tcgetpgrp(tty, this.sid()) : this.pid };
|
|
9631
9632
|
case "tty-pgrp-set":
|
|
9632
|
-
if (jobs) jobs.tcsetpgrp(this.pid, tty, req.pgrp);
|
|
9633
|
+
if (jobs) jobs.tcsetpgrp(this.pid, tty, req.pgrp, this.options.settling?.() ?? false);
|
|
9633
9634
|
else if (req.pgrp !== this.pid) throw new KernelError("EPERM");
|
|
9634
9635
|
return { ok: true, kind: "void" };
|
|
9635
9636
|
}
|
|
@@ -10014,6 +10015,7 @@ function processOptions(opts, header3, hooks) {
|
|
|
10014
10015
|
...inherited(opts),
|
|
10015
10016
|
...opts.identity ? { identity: opts.identity } : {},
|
|
10016
10017
|
...opts.onSyscall ? { onSyscall: opts.onSyscall } : {},
|
|
10018
|
+
...opts.settling ? { settling: opts.settling } : {},
|
|
10017
10019
|
spawner: opts.spawner,
|
|
10018
10020
|
forker: opts.forker,
|
|
10019
10021
|
fs: opts.fs,
|
|
@@ -10186,6 +10188,7 @@ function spawnWasmProcess(opts) {
|
|
|
10186
10188
|
// src/kernel/jobs.ts
|
|
10187
10189
|
var JobTable = class {
|
|
10188
10190
|
members = /* @__PURE__ */ new Map();
|
|
10191
|
+
handoffs = /* @__PURE__ */ new Map();
|
|
10189
10192
|
foreground = /* @__PURE__ */ new Map();
|
|
10190
10193
|
terminals = /* @__PURE__ */ new Map();
|
|
10191
10194
|
add(pid, parentPid, signal, terminal) {
|
|
@@ -10205,7 +10208,12 @@ var JobTable = class {
|
|
|
10205
10208
|
return [...this.members.values()];
|
|
10206
10209
|
}
|
|
10207
10210
|
remove(pid) {
|
|
10211
|
+
const member = this.members.get(pid);
|
|
10208
10212
|
this.members.delete(pid);
|
|
10213
|
+
if (member) this.prune(member.pgid);
|
|
10214
|
+
}
|
|
10215
|
+
prune(pgid) {
|
|
10216
|
+
if (![...this.members.values()].some((m) => m.pgid === pgid)) this.handoffs.delete(pgid);
|
|
10209
10217
|
}
|
|
10210
10218
|
exec(pid, child, adopt = false) {
|
|
10211
10219
|
const member = this.members.get(child);
|
|
@@ -10269,7 +10277,12 @@ var JobTable = class {
|
|
|
10269
10277
|
if (id2 === target.sid) throw new KernelError("EPERM");
|
|
10270
10278
|
const exists = [...this.members.values()].some((m) => m.pgid === group && m.sid === target.sid);
|
|
10271
10279
|
if (group !== id2 && !exists) throw new KernelError("EPERM");
|
|
10280
|
+
const left = target.pgid;
|
|
10272
10281
|
target.pgid = group;
|
|
10282
|
+
this.prune(left);
|
|
10283
|
+
}
|
|
10284
|
+
get handoffCount() {
|
|
10285
|
+
return this.handoffs.size;
|
|
10273
10286
|
}
|
|
10274
10287
|
getpgid(caller, pid) {
|
|
10275
10288
|
return this.byId(pid || this.idOf(caller)).pgid;
|
|
@@ -10322,12 +10335,24 @@ var JobTable = class {
|
|
|
10322
10335
|
tcgetpgrp(tty, fallback) {
|
|
10323
10336
|
return this.foreground.get(tty) ?? fallback;
|
|
10324
10337
|
}
|
|
10325
|
-
tcsetpgrp(caller, tty, pgid) {
|
|
10338
|
+
tcsetpgrp(caller, tty, pgid, settling = false) {
|
|
10326
10339
|
const self = this.member(caller);
|
|
10327
10340
|
const inSession = [...this.members.values()].some((m) => m.pgid === pgid && m.sid === self.sid);
|
|
10328
10341
|
if (!inSession) throw new KernelError("EPERM");
|
|
10342
|
+
const current = this.foreground.get(tty);
|
|
10343
|
+
if (settling && pgid === self.pgid && current !== pgid && this.reclaimed(pgid, self.ppid))
|
|
10344
|
+
return;
|
|
10345
|
+
if (pgid !== self.pgid) this.handoffs.set(pgid, { by: caller, reclaimed: false });
|
|
10346
|
+
else if (current !== void 0) {
|
|
10347
|
+
const handoff = this.handoffs.get(current);
|
|
10348
|
+
if (handoff?.by === caller) handoff.reclaimed = true;
|
|
10349
|
+
}
|
|
10329
10350
|
this.foreground.set(tty, pgid);
|
|
10330
10351
|
}
|
|
10352
|
+
reclaimed(pgid, parent) {
|
|
10353
|
+
const handoff = this.handoffs.get(pgid);
|
|
10354
|
+
return handoff?.reclaimed === true && handoff.by === parent;
|
|
10355
|
+
}
|
|
10331
10356
|
signalOwnedForeground(tty, sig) {
|
|
10332
10357
|
const pgid = this.foreground.get(tty);
|
|
10333
10358
|
if (pgid !== void 0) this.killGroup(pgid, sig);
|
|
@@ -10371,6 +10396,9 @@ var SettlingChildren = class {
|
|
|
10371
10396
|
this.parked = this.parked.filter((p) => p.pgid !== pgid);
|
|
10372
10397
|
this.held = this.held.filter((h) => !(h.copy && h.pgid === pgid));
|
|
10373
10398
|
}
|
|
10399
|
+
isSettling(pid) {
|
|
10400
|
+
return this.children.has(pid);
|
|
10401
|
+
}
|
|
10374
10402
|
syscall(pid, op) {
|
|
10375
10403
|
const child = this.children.get(pid);
|
|
10376
10404
|
if (!child) return;
|
|
@@ -11986,6 +12014,7 @@ var Launcher = class {
|
|
|
11986
12014
|
this.decide(pid);
|
|
11987
12015
|
this.settling.syscall(pid, call.op);
|
|
11988
12016
|
},
|
|
12017
|
+
settling: () => this.settling.isSettling(pid),
|
|
11989
12018
|
...req.ignored ? { ignored: req.ignored } : {},
|
|
11990
12019
|
...req.umask !== void 0 ? { umask: req.umask } : {},
|
|
11991
12020
|
cred: req.cred,
|