@ai-ecoverse/slicc-kernel 1.48.0 → 1.48.2
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 -9
- package/dist/kernel-worker.js +32 -7
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +9722 -9573
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +42 -9
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +119 -34
- package/dist/process-worker.js.map +3 -3
- package/package.json +4 -4
package/dist/node.js
CHANGED
|
@@ -7814,9 +7814,13 @@ var KernelTty = class {
|
|
|
7814
7814
|
tcgets() {
|
|
7815
7815
|
return { ...this.termios, c_cc: [...this.termios.c_cc] };
|
|
7816
7816
|
}
|
|
7817
|
-
tcsets(termios) {
|
|
7817
|
+
tcsets(termios, flush = false) {
|
|
7818
7818
|
const wasCanonical = this.canonical;
|
|
7819
7819
|
this.termios = { ...termios, c_cc: [...termios.c_cc] };
|
|
7820
|
+
if (flush) {
|
|
7821
|
+
this.line = [];
|
|
7822
|
+
this.readable = [];
|
|
7823
|
+
}
|
|
7820
7824
|
if (wasCanonical && !this.canonical && this.line.length > 0) {
|
|
7821
7825
|
this.readable.push(Uint8Array.from(this.line));
|
|
7822
7826
|
this.line = [];
|
|
@@ -9199,6 +9203,7 @@ function isWasmSyscall(req) {
|
|
|
9199
9203
|
return typeof op === "string" && SYSCALL_OPS.has(op);
|
|
9200
9204
|
}
|
|
9201
9205
|
var MAX_READ = 1024 * 1024;
|
|
9206
|
+
var KEYBOARD = /* @__PURE__ */ new Set([SIG.INT, SIG.QUIT, SIG.TSTP]);
|
|
9202
9207
|
var DEFAULT_UMASK = 18;
|
|
9203
9208
|
var DYING = { ok: false, errno: "EINTR", message: "the process is being killed" };
|
|
9204
9209
|
var HOSTS_ONLY = new Resolver({ routes: new Routes() });
|
|
@@ -9217,6 +9222,8 @@ var WasmProcess = class {
|
|
|
9217
9222
|
execTermsig;
|
|
9218
9223
|
stopped = 0;
|
|
9219
9224
|
stops = 0;
|
|
9225
|
+
owed = false;
|
|
9226
|
+
waits = 0;
|
|
9220
9227
|
resumed = Promise.resolve();
|
|
9221
9228
|
wake;
|
|
9222
9229
|
stateListeners = [];
|
|
@@ -9272,6 +9279,7 @@ var WasmProcess = class {
|
|
|
9272
9279
|
return "terminate";
|
|
9273
9280
|
}
|
|
9274
9281
|
this.options.onPending?.(sig);
|
|
9282
|
+
if (this.options.jobs?.keyboard && KEYBOARD.has(sig)) this.owed = true;
|
|
9275
9283
|
const blocked = this.interrupt;
|
|
9276
9284
|
this.interrupt = new AbortController();
|
|
9277
9285
|
blocked.abort();
|
|
@@ -9316,8 +9324,10 @@ var WasmProcess = class {
|
|
|
9316
9324
|
await this.resumed;
|
|
9317
9325
|
if (this.dying) return DYING;
|
|
9318
9326
|
const stops = this.stops;
|
|
9327
|
+
const waits = this.waits;
|
|
9319
9328
|
const result = await this.dispatch(req, cancelled);
|
|
9320
9329
|
if (this.dying) return DYING;
|
|
9330
|
+
if (!result.ok && result.errno === "EINTR" && this.waits !== waits) this.owed = false;
|
|
9321
9331
|
const restart = !result.ok && result.errno === "EINTR" && this.stops !== stops;
|
|
9322
9332
|
if (restart && !this.options.hasPending?.()) continue;
|
|
9323
9333
|
await this.resumed;
|
|
@@ -9370,8 +9380,11 @@ var WasmProcess = class {
|
|
|
9370
9380
|
refuseIfPending(restart) {
|
|
9371
9381
|
if (restart && this.options.hasPending?.()) throw new KernelError("EINTR");
|
|
9372
9382
|
}
|
|
9373
|
-
blockingSignal(cancelled) {
|
|
9374
|
-
if (this.
|
|
9383
|
+
blockingSignal(cancelled, owing = true) {
|
|
9384
|
+
if (owing) this.waits++;
|
|
9385
|
+
if (this.options.hasPending?.() || cancelled?.aborted || owing && this.owed) {
|
|
9386
|
+
throw new KernelError("EINTR");
|
|
9387
|
+
}
|
|
9375
9388
|
return cancelled ? AbortSignal.any([this.interrupt.signal, cancelled]) : this.interrupt.signal;
|
|
9376
9389
|
}
|
|
9377
9390
|
async read(req, cancelled) {
|
|
@@ -9517,7 +9530,7 @@ var WasmProcess = class {
|
|
|
9517
9530
|
return { ok: true, kind: "json", json: this.options.jobs?.terminalNames() ?? [] };
|
|
9518
9531
|
case "fd-select": {
|
|
9519
9532
|
const { read, write, timeoutMs } = req;
|
|
9520
|
-
const signal = this.blockingSignal(cancelled);
|
|
9533
|
+
const signal = this.blockingSignal(cancelled, timeoutMs !== 0);
|
|
9521
9534
|
const selected = await selectFds(this.fds, read, write, timeoutMs, signal);
|
|
9522
9535
|
return { ok: true, kind: "json", json: selected };
|
|
9523
9536
|
}
|
|
@@ -9605,6 +9618,7 @@ var WasmProcess = class {
|
|
|
9605
9618
|
fdInfo(fd) {
|
|
9606
9619
|
const file = this.fds.get(fd).file;
|
|
9607
9620
|
const flags = this.fds.statusFlags(fd);
|
|
9621
|
+
const terminal = (file.tty ?? file.pty?.slave)?.name;
|
|
9608
9622
|
return {
|
|
9609
9623
|
tty: file.tty !== void 0,
|
|
9610
9624
|
kind: file instanceof KernelSocket ? "socket" : kernelFdKind(file),
|
|
@@ -9613,7 +9627,8 @@ var WasmProcess = class {
|
|
|
9613
9627
|
...this.fds.closesOnExec(fd) ? { cloexec: true } : {},
|
|
9614
9628
|
...file.read && !file.write ? { access: "read" } : {},
|
|
9615
9629
|
...file.write && !file.read ? { access: "write" } : {},
|
|
9616
|
-
...file.tty?.name ? { name: file.tty.name } : file.pty ? { name: "/dev/ptmx" } : {}
|
|
9630
|
+
...file.tty?.name ? { name: file.tty.name } : file.pty ? { name: "/dev/ptmx" } : {},
|
|
9631
|
+
...terminal ? { terminal } : {}
|
|
9617
9632
|
};
|
|
9618
9633
|
}
|
|
9619
9634
|
ttySyscall(req) {
|
|
@@ -9623,7 +9638,7 @@ var WasmProcess = class {
|
|
|
9623
9638
|
case "tty-get":
|
|
9624
9639
|
return { ok: true, kind: "json", json: tty.tcgets() };
|
|
9625
9640
|
case "tty-set":
|
|
9626
|
-
tty.tcsets(req.termios);
|
|
9641
|
+
tty.tcsets(req.termios, req.flush === true);
|
|
9627
9642
|
return { ok: true, kind: "void" };
|
|
9628
9643
|
case "tty-winsz":
|
|
9629
9644
|
return { ok: true, kind: "json", json: tty.winsize() };
|
|
@@ -10191,6 +10206,7 @@ var JobTable = class {
|
|
|
10191
10206
|
handoffs = /* @__PURE__ */ new Map();
|
|
10192
10207
|
foreground = /* @__PURE__ */ new Map();
|
|
10193
10208
|
terminals = /* @__PURE__ */ new Map();
|
|
10209
|
+
keyboard = false;
|
|
10194
10210
|
add(pid, parentPid, signal, terminal) {
|
|
10195
10211
|
const parent = parentPid === void 0 ? void 0 : this.members.get(parentPid);
|
|
10196
10212
|
if (!parent && terminal) this.terminals.set(pid, terminal);
|
|
@@ -10360,6 +10376,14 @@ var JobTable = class {
|
|
|
10360
10376
|
signalForeground(tty, fallback, sig) {
|
|
10361
10377
|
this.killGroup(this.tcgetpgrp(tty, fallback), sig);
|
|
10362
10378
|
}
|
|
10379
|
+
fromKeyboard(send) {
|
|
10380
|
+
this.keyboard = true;
|
|
10381
|
+
try {
|
|
10382
|
+
send();
|
|
10383
|
+
} finally {
|
|
10384
|
+
this.keyboard = false;
|
|
10385
|
+
}
|
|
10386
|
+
}
|
|
10363
10387
|
};
|
|
10364
10388
|
|
|
10365
10389
|
// src/kernel/settling.ts
|
|
@@ -12195,7 +12219,8 @@ var Launcher = class {
|
|
|
12195
12219
|
keySignal(tty, fallback, sig, send) {
|
|
12196
12220
|
const pgid = this.jobs.tcgetpgrp(tty, fallback);
|
|
12197
12221
|
const foreground = () => this.jobs.tcgetpgrp(tty, fallback);
|
|
12198
|
-
this.
|
|
12222
|
+
const keyed = () => this.jobs.fromKeyboard(send);
|
|
12223
|
+
this.settling.deliver(sig, pgid, keyed, tty.reading ? void 0 : foreground);
|
|
12199
12224
|
}
|
|
12200
12225
|
umaskOf(pid) {
|
|
12201
12226
|
return this.processes.get(pid)?.umask?.() ?? DEFAULT_UMASK;
|
|
@@ -13527,13 +13552,18 @@ function nodeWorker(file, live, closed) {
|
|
|
13527
13552
|
}
|
|
13528
13553
|
};
|
|
13529
13554
|
const worker = closed ? void 0 : new Worker(file);
|
|
13555
|
+
let ending = false;
|
|
13530
13556
|
if (worker) {
|
|
13531
13557
|
const kill = () => {
|
|
13558
|
+
ending = true;
|
|
13532
13559
|
void worker.terminate();
|
|
13533
13560
|
fail3(TERMINATED);
|
|
13534
13561
|
};
|
|
13535
13562
|
live.add(kill);
|
|
13536
|
-
worker.once("exit", () =>
|
|
13563
|
+
worker.once("exit", (code) => {
|
|
13564
|
+
live.delete(kill);
|
|
13565
|
+
if (!ending) fail3(`the process worker exited with ${code}`);
|
|
13566
|
+
});
|
|
13537
13567
|
worker.on("error", (err) => fail3(String(err)));
|
|
13538
13568
|
} else {
|
|
13539
13569
|
setTimeout(() => fail3(TERMINATED), 0);
|
|
@@ -13554,7 +13584,10 @@ function nodeWorker(file, live, closed) {
|
|
|
13554
13584
|
const listener = messages.get(handler);
|
|
13555
13585
|
if (listener) worker?.off("message", listener);
|
|
13556
13586
|
},
|
|
13557
|
-
terminate: () =>
|
|
13587
|
+
terminate: () => {
|
|
13588
|
+
ending = true;
|
|
13589
|
+
void worker?.terminate();
|
|
13590
|
+
}
|
|
13558
13591
|
};
|
|
13559
13592
|
}
|
|
13560
13593
|
function textOf(on) {
|