@ai-ecoverse/slicc-kernel 1.33.0 → 1.34.1
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 +4 -2
- package/dist/kernel-worker.js +61 -29
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +157 -27
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +66 -33
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +157 -27
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -1
package/dist/node.js
CHANGED
|
@@ -339,14 +339,6 @@ function sinkFile(onData) {
|
|
|
339
339
|
}
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
|
-
function nullFile() {
|
|
343
|
-
return new OpenFile({
|
|
344
|
-
read: async () => new Uint8Array(0),
|
|
345
|
-
write: async (bytes) => bytes.length,
|
|
346
|
-
close: () => {
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
342
|
function written(device, bytes) {
|
|
351
343
|
if (device === "full" && bytes.length > 0) throw new KernelError("ENOSPC");
|
|
352
344
|
return bytes.length;
|
|
@@ -3519,7 +3511,7 @@ var ChildTable = class {
|
|
|
3519
3511
|
captured.set(n, chunks2);
|
|
3520
3512
|
return sinkFile((bytes) => chunks2.push(bytes));
|
|
3521
3513
|
}
|
|
3522
|
-
return
|
|
3514
|
+
return deviceFile("null");
|
|
3523
3515
|
}
|
|
3524
3516
|
async wait(pid, nohang, signal, flags = {}) {
|
|
3525
3517
|
let interrupt;
|
|
@@ -6286,6 +6278,8 @@ var KernelTty = class {
|
|
|
6286
6278
|
waiters = [];
|
|
6287
6279
|
hungUp = false;
|
|
6288
6280
|
name;
|
|
6281
|
+
onRead;
|
|
6282
|
+
readers = 0;
|
|
6289
6283
|
screen;
|
|
6290
6284
|
signal;
|
|
6291
6285
|
constructor(screen, signal) {
|
|
@@ -6436,7 +6430,19 @@ var KernelTty = class {
|
|
|
6436
6430
|
}
|
|
6437
6431
|
this.screen.write(Uint8Array.from(out));
|
|
6438
6432
|
}
|
|
6433
|
+
get reading() {
|
|
6434
|
+
return this.readers > 0;
|
|
6435
|
+
}
|
|
6439
6436
|
async read(max, signal) {
|
|
6437
|
+
this.onRead?.();
|
|
6438
|
+
this.readers++;
|
|
6439
|
+
try {
|
|
6440
|
+
return await this.take(max, signal);
|
|
6441
|
+
} finally {
|
|
6442
|
+
this.readers--;
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
async take(max, signal) {
|
|
6440
6446
|
while (this.readable.length === 0) {
|
|
6441
6447
|
if (this.hungUp) return new Uint8Array(0);
|
|
6442
6448
|
await this.changed(signal);
|
|
@@ -6501,13 +6507,14 @@ var PtyPair = class {
|
|
|
6501
6507
|
slaveSeen = false;
|
|
6502
6508
|
index;
|
|
6503
6509
|
onFree;
|
|
6504
|
-
constructor(index, signal, onFree) {
|
|
6510
|
+
constructor(index, signal, onFree, onRead) {
|
|
6505
6511
|
this.index = index;
|
|
6506
6512
|
this.onFree = onFree;
|
|
6507
6513
|
this.slave = new KernelTty(
|
|
6508
6514
|
{ write: (bytes) => this.fromSlave(bytes) },
|
|
6509
6515
|
(sig) => signal(this.slave, sig)
|
|
6510
6516
|
);
|
|
6517
|
+
if (onRead) this.slave.onRead = () => onRead(this.slave);
|
|
6511
6518
|
this.slave.name = `/dev/pts/${index}`;
|
|
6512
6519
|
}
|
|
6513
6520
|
master() {
|
|
@@ -6605,13 +6612,15 @@ var PtyPair = class {
|
|
|
6605
6612
|
var PtyTable = class {
|
|
6606
6613
|
pairs = /* @__PURE__ */ new Map();
|
|
6607
6614
|
signal;
|
|
6608
|
-
|
|
6615
|
+
onRead;
|
|
6616
|
+
constructor(signal, onRead) {
|
|
6609
6617
|
this.signal = signal;
|
|
6618
|
+
this.onRead = onRead;
|
|
6610
6619
|
}
|
|
6611
6620
|
open() {
|
|
6612
6621
|
let index = 0;
|
|
6613
6622
|
while (this.pairs.has(index)) index += 1;
|
|
6614
|
-
const pair = new PtyPair(index, this.signal, (p) => this.pairs.delete(p.index));
|
|
6623
|
+
const pair = new PtyPair(index, this.signal, (p) => this.pairs.delete(p.index), this.onRead);
|
|
6615
6624
|
this.pairs.set(index, pair);
|
|
6616
6625
|
return { pair, master: pair.master() };
|
|
6617
6626
|
}
|
|
@@ -8164,6 +8173,7 @@ var WasmProcess = class {
|
|
|
8164
8173
|
async exit() {
|
|
8165
8174
|
if (this.exited) return;
|
|
8166
8175
|
this.exited = true;
|
|
8176
|
+
this.die();
|
|
8167
8177
|
this.clearAlarm();
|
|
8168
8178
|
this.interrupt.abort();
|
|
8169
8179
|
this.options.locks?.release(this.pid);
|
|
@@ -8576,13 +8586,16 @@ var SETUP_OPS = /* @__PURE__ */ new Set([
|
|
|
8576
8586
|
"fd-info",
|
|
8577
8587
|
"sig-mask",
|
|
8578
8588
|
"proc-setpgid",
|
|
8579
|
-
"tty-pgrp-set"
|
|
8589
|
+
"tty-pgrp-set",
|
|
8590
|
+
"proc-exec",
|
|
8591
|
+
"proc-spawn"
|
|
8580
8592
|
]);
|
|
8581
|
-
var SETTLE_MS =
|
|
8593
|
+
var SETTLE_MS = 2e3;
|
|
8582
8594
|
var KEY_SIGNALS = /* @__PURE__ */ new Set([2, 3, 20]);
|
|
8583
8595
|
var SettlingChildren = class {
|
|
8584
8596
|
children = /* @__PURE__ */ new Map();
|
|
8585
8597
|
held = [];
|
|
8598
|
+
parked = [];
|
|
8586
8599
|
pgidOf;
|
|
8587
8600
|
settleMs;
|
|
8588
8601
|
constructor(pgidOf, settleMs = SETTLE_MS) {
|
|
@@ -8590,7 +8603,15 @@ var SettlingChildren = class {
|
|
|
8590
8603
|
this.settleMs = settleMs;
|
|
8591
8604
|
}
|
|
8592
8605
|
started(pid, ppid) {
|
|
8593
|
-
this.children.
|
|
8606
|
+
const parent = this.children.get(ppid);
|
|
8607
|
+
this.children.set(pid, parent ? { ppid: parent.ppid, execer: ppid } : { ppid });
|
|
8608
|
+
const group = this.pgidOf(ppid);
|
|
8609
|
+
for (const p of this.parked) if (p.pgid === group) this.held.push({ ...p, copy: true });
|
|
8610
|
+
this.parked = this.parked.filter((p) => p.pgid !== group);
|
|
8611
|
+
}
|
|
8612
|
+
reading(pgid) {
|
|
8613
|
+
this.parked = this.parked.filter((p) => p.pgid !== pgid);
|
|
8614
|
+
this.held = this.held.filter((h) => !(h.copy && h.pgid === pgid));
|
|
8594
8615
|
}
|
|
8595
8616
|
syscall(pid, op) {
|
|
8596
8617
|
const child = this.children.get(pid);
|
|
@@ -8606,13 +8627,25 @@ var SettlingChildren = class {
|
|
|
8606
8627
|
if (!child) return;
|
|
8607
8628
|
clearTimeout(child.timer);
|
|
8608
8629
|
this.children.delete(pid);
|
|
8630
|
+
if (child.execer !== void 0) this.settled(child.execer);
|
|
8609
8631
|
const ready2 = this.held.filter((h) => !this.blocking(h.pgid));
|
|
8610
8632
|
this.held = this.held.filter((h) => this.blocking(h.pgid));
|
|
8611
8633
|
for (const h of ready2) h.send();
|
|
8612
8634
|
}
|
|
8613
|
-
deliver(sig, pgid, send) {
|
|
8614
|
-
if (KEY_SIGNALS.has(sig)
|
|
8615
|
-
|
|
8635
|
+
deliver(sig, pgid, send, foreground) {
|
|
8636
|
+
if (!KEY_SIGNALS.has(sig)) {
|
|
8637
|
+
send();
|
|
8638
|
+
} else if (this.blocking(pgid)) {
|
|
8639
|
+
this.held.push({ pgid, send });
|
|
8640
|
+
} else if (foreground) {
|
|
8641
|
+
send();
|
|
8642
|
+
const moved2 = () => {
|
|
8643
|
+
if (foreground() !== pgid) send();
|
|
8644
|
+
};
|
|
8645
|
+
this.parked.push({ pgid, send: moved2 });
|
|
8646
|
+
} else {
|
|
8647
|
+
send();
|
|
8648
|
+
}
|
|
8616
8649
|
}
|
|
8617
8650
|
blocking(pgid) {
|
|
8618
8651
|
for (const { ppid } of this.children.values()) if (this.pgidOf(ppid) === pgid) return true;
|
|
@@ -9891,11 +9924,8 @@ var Launcher = class {
|
|
|
9891
9924
|
locks = new LockTable();
|
|
9892
9925
|
settling = new SettlingChildren((pid) => this.jobs.pgidOf(pid));
|
|
9893
9926
|
ptys = new PtyTable(
|
|
9894
|
-
(tty, sig) => this.
|
|
9895
|
-
|
|
9896
|
-
this.jobs.tcgetpgrp(tty, 0),
|
|
9897
|
-
() => this.jobs.signalOwnedForeground(tty, sig)
|
|
9898
|
-
)
|
|
9927
|
+
(tty, sig) => this.keySignal(tty, 0, sig, () => this.jobs.signalOwnedForeground(tty, sig)),
|
|
9928
|
+
(tty) => this.settling.reading(this.jobs.tcgetpgrp(tty, 0))
|
|
9899
9929
|
);
|
|
9900
9930
|
net = new LoopbackNet();
|
|
9901
9931
|
cdp;
|
|
@@ -10311,6 +10341,11 @@ var Launcher = class {
|
|
|
10311
10341
|
})
|
|
10312
10342
|
);
|
|
10313
10343
|
}
|
|
10344
|
+
keySignal(tty, fallback, sig, send) {
|
|
10345
|
+
const pgid = this.jobs.tcgetpgrp(tty, fallback);
|
|
10346
|
+
const foreground = () => this.jobs.tcgetpgrp(tty, fallback);
|
|
10347
|
+
this.settling.deliver(sig, pgid, send, tty.reading ? void 0 : foreground);
|
|
10348
|
+
}
|
|
10314
10349
|
ignoredBy(pid, fork = false) {
|
|
10315
10350
|
return this.processes.get(pid)?.ignoredSignals(fork) ?? 0;
|
|
10316
10351
|
}
|
|
@@ -10506,12 +10541,9 @@ var Launcher = class {
|
|
|
10506
10541
|
let leader = 0;
|
|
10507
10542
|
const tty = new KernelTty(
|
|
10508
10543
|
{ write: (bytes) => options.onData(bytes.slice()) },
|
|
10509
|
-
(sig) => this.
|
|
10510
|
-
sig,
|
|
10511
|
-
this.jobs.tcgetpgrp(tty, leader),
|
|
10512
|
-
() => this.jobs.signalForeground(tty, leader, sig)
|
|
10513
|
-
)
|
|
10544
|
+
(sig) => this.keySignal(tty, leader, sig, () => this.jobs.signalForeground(tty, leader, sig))
|
|
10514
10545
|
);
|
|
10546
|
+
tty.onRead = () => this.settling.reading(this.jobs.tcgetpgrp(tty, leader));
|
|
10515
10547
|
tty.name = `/dev/tty${++this.terminals}`;
|
|
10516
10548
|
tty.setSize(options.cols ?? 80, options.rows ?? 24);
|
|
10517
10549
|
const fds = new FdTable();
|
|
@@ -10560,7 +10592,7 @@ var Launcher = class {
|
|
|
10560
10592
|
return { status: NOT_FOUND, stdout: concat5(out), stderr: concat5(err) };
|
|
10561
10593
|
}
|
|
10562
10594
|
const fds = new FdTable();
|
|
10563
|
-
fds.installAt(0, options.stdin ? bytesSource(options.stdin) :
|
|
10595
|
+
fds.installAt(0, options.stdin ? bytesSource(options.stdin) : deviceFile("null"));
|
|
10564
10596
|
fds.installAt(1, sinkFile(stdout));
|
|
10565
10597
|
fds.installAt(2, sinkFile(stderr));
|
|
10566
10598
|
const group = options.pgid !== void 0 ? { pgid: options.pgid } : {};
|
|
@@ -11499,10 +11531,11 @@ function hostfsFetchOf(options) {
|
|
|
11499
11531
|
if (hostfsOrigin === void 0) return hostfsFetch ? { hostfsFetch } : {};
|
|
11500
11532
|
const base = hostfsFetch ?? ((url, init) => fetch(url, init));
|
|
11501
11533
|
return {
|
|
11502
|
-
hostfsFetch: (url, init) =>
|
|
11503
|
-
|
|
11504
|
-
headers
|
|
11505
|
-
|
|
11534
|
+
hostfsFetch: (url, init) => {
|
|
11535
|
+
const headers = new Headers(init.headers);
|
|
11536
|
+
headers.set("Origin", hostfsOrigin);
|
|
11537
|
+
return base(url, { ...init, headers });
|
|
11538
|
+
}
|
|
11506
11539
|
};
|
|
11507
11540
|
}
|
|
11508
11541
|
function nodeTransport() {
|