@ai-ecoverse/slicc-kernel 1.33.0 → 1.34.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 +3 -1
- package/dist/kernel-worker.js +59 -19
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +70 -17
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +59 -19
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +70 -17
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -1
package/dist/node.js
CHANGED
|
@@ -6286,6 +6286,8 @@ var KernelTty = class {
|
|
|
6286
6286
|
waiters = [];
|
|
6287
6287
|
hungUp = false;
|
|
6288
6288
|
name;
|
|
6289
|
+
onRead;
|
|
6290
|
+
readers = 0;
|
|
6289
6291
|
screen;
|
|
6290
6292
|
signal;
|
|
6291
6293
|
constructor(screen, signal) {
|
|
@@ -6436,7 +6438,19 @@ var KernelTty = class {
|
|
|
6436
6438
|
}
|
|
6437
6439
|
this.screen.write(Uint8Array.from(out));
|
|
6438
6440
|
}
|
|
6441
|
+
get reading() {
|
|
6442
|
+
return this.readers > 0;
|
|
6443
|
+
}
|
|
6439
6444
|
async read(max, signal) {
|
|
6445
|
+
this.onRead?.();
|
|
6446
|
+
this.readers++;
|
|
6447
|
+
try {
|
|
6448
|
+
return await this.take(max, signal);
|
|
6449
|
+
} finally {
|
|
6450
|
+
this.readers--;
|
|
6451
|
+
}
|
|
6452
|
+
}
|
|
6453
|
+
async take(max, signal) {
|
|
6440
6454
|
while (this.readable.length === 0) {
|
|
6441
6455
|
if (this.hungUp) return new Uint8Array(0);
|
|
6442
6456
|
await this.changed(signal);
|
|
@@ -6501,13 +6515,14 @@ var PtyPair = class {
|
|
|
6501
6515
|
slaveSeen = false;
|
|
6502
6516
|
index;
|
|
6503
6517
|
onFree;
|
|
6504
|
-
constructor(index, signal, onFree) {
|
|
6518
|
+
constructor(index, signal, onFree, onRead) {
|
|
6505
6519
|
this.index = index;
|
|
6506
6520
|
this.onFree = onFree;
|
|
6507
6521
|
this.slave = new KernelTty(
|
|
6508
6522
|
{ write: (bytes) => this.fromSlave(bytes) },
|
|
6509
6523
|
(sig) => signal(this.slave, sig)
|
|
6510
6524
|
);
|
|
6525
|
+
if (onRead) this.slave.onRead = () => onRead(this.slave);
|
|
6511
6526
|
this.slave.name = `/dev/pts/${index}`;
|
|
6512
6527
|
}
|
|
6513
6528
|
master() {
|
|
@@ -6605,13 +6620,15 @@ var PtyPair = class {
|
|
|
6605
6620
|
var PtyTable = class {
|
|
6606
6621
|
pairs = /* @__PURE__ */ new Map();
|
|
6607
6622
|
signal;
|
|
6608
|
-
|
|
6623
|
+
onRead;
|
|
6624
|
+
constructor(signal, onRead) {
|
|
6609
6625
|
this.signal = signal;
|
|
6626
|
+
this.onRead = onRead;
|
|
6610
6627
|
}
|
|
6611
6628
|
open() {
|
|
6612
6629
|
let index = 0;
|
|
6613
6630
|
while (this.pairs.has(index)) index += 1;
|
|
6614
|
-
const pair = new PtyPair(index, this.signal, (p) => this.pairs.delete(p.index));
|
|
6631
|
+
const pair = new PtyPair(index, this.signal, (p) => this.pairs.delete(p.index), this.onRead);
|
|
6615
6632
|
this.pairs.set(index, pair);
|
|
6616
6633
|
return { pair, master: pair.master() };
|
|
6617
6634
|
}
|
|
@@ -8164,6 +8181,7 @@ var WasmProcess = class {
|
|
|
8164
8181
|
async exit() {
|
|
8165
8182
|
if (this.exited) return;
|
|
8166
8183
|
this.exited = true;
|
|
8184
|
+
this.die();
|
|
8167
8185
|
this.clearAlarm();
|
|
8168
8186
|
this.interrupt.abort();
|
|
8169
8187
|
this.options.locks?.release(this.pid);
|
|
@@ -8576,13 +8594,16 @@ var SETUP_OPS = /* @__PURE__ */ new Set([
|
|
|
8576
8594
|
"fd-info",
|
|
8577
8595
|
"sig-mask",
|
|
8578
8596
|
"proc-setpgid",
|
|
8579
|
-
"tty-pgrp-set"
|
|
8597
|
+
"tty-pgrp-set",
|
|
8598
|
+
"proc-exec",
|
|
8599
|
+
"proc-spawn"
|
|
8580
8600
|
]);
|
|
8581
|
-
var SETTLE_MS =
|
|
8601
|
+
var SETTLE_MS = 2e3;
|
|
8582
8602
|
var KEY_SIGNALS = /* @__PURE__ */ new Set([2, 3, 20]);
|
|
8583
8603
|
var SettlingChildren = class {
|
|
8584
8604
|
children = /* @__PURE__ */ new Map();
|
|
8585
8605
|
held = [];
|
|
8606
|
+
parked = [];
|
|
8586
8607
|
pgidOf;
|
|
8587
8608
|
settleMs;
|
|
8588
8609
|
constructor(pgidOf, settleMs = SETTLE_MS) {
|
|
@@ -8590,7 +8611,15 @@ var SettlingChildren = class {
|
|
|
8590
8611
|
this.settleMs = settleMs;
|
|
8591
8612
|
}
|
|
8592
8613
|
started(pid, ppid) {
|
|
8593
|
-
this.children.
|
|
8614
|
+
const parent = this.children.get(ppid);
|
|
8615
|
+
this.children.set(pid, parent ? { ppid: parent.ppid, execer: ppid } : { ppid });
|
|
8616
|
+
const group = this.pgidOf(ppid);
|
|
8617
|
+
for (const p of this.parked) if (p.pgid === group) this.held.push({ ...p, copy: true });
|
|
8618
|
+
this.parked = this.parked.filter((p) => p.pgid !== group);
|
|
8619
|
+
}
|
|
8620
|
+
reading(pgid) {
|
|
8621
|
+
this.parked = this.parked.filter((p) => p.pgid !== pgid);
|
|
8622
|
+
this.held = this.held.filter((h) => !(h.copy && h.pgid === pgid));
|
|
8594
8623
|
}
|
|
8595
8624
|
syscall(pid, op) {
|
|
8596
8625
|
const child = this.children.get(pid);
|
|
@@ -8606,13 +8635,25 @@ var SettlingChildren = class {
|
|
|
8606
8635
|
if (!child) return;
|
|
8607
8636
|
clearTimeout(child.timer);
|
|
8608
8637
|
this.children.delete(pid);
|
|
8638
|
+
if (child.execer !== void 0) this.settled(child.execer);
|
|
8609
8639
|
const ready2 = this.held.filter((h) => !this.blocking(h.pgid));
|
|
8610
8640
|
this.held = this.held.filter((h) => this.blocking(h.pgid));
|
|
8611
8641
|
for (const h of ready2) h.send();
|
|
8612
8642
|
}
|
|
8613
|
-
deliver(sig, pgid, send) {
|
|
8614
|
-
if (KEY_SIGNALS.has(sig)
|
|
8615
|
-
|
|
8643
|
+
deliver(sig, pgid, send, foreground) {
|
|
8644
|
+
if (!KEY_SIGNALS.has(sig)) {
|
|
8645
|
+
send();
|
|
8646
|
+
} else if (this.blocking(pgid)) {
|
|
8647
|
+
this.held.push({ pgid, send });
|
|
8648
|
+
} else if (foreground) {
|
|
8649
|
+
send();
|
|
8650
|
+
const moved2 = () => {
|
|
8651
|
+
if (foreground() !== pgid) send();
|
|
8652
|
+
};
|
|
8653
|
+
this.parked.push({ pgid, send: moved2 });
|
|
8654
|
+
} else {
|
|
8655
|
+
send();
|
|
8656
|
+
}
|
|
8616
8657
|
}
|
|
8617
8658
|
blocking(pgid) {
|
|
8618
8659
|
for (const { ppid } of this.children.values()) if (this.pgidOf(ppid) === pgid) return true;
|
|
@@ -9891,11 +9932,8 @@ var Launcher = class {
|
|
|
9891
9932
|
locks = new LockTable();
|
|
9892
9933
|
settling = new SettlingChildren((pid) => this.jobs.pgidOf(pid));
|
|
9893
9934
|
ptys = new PtyTable(
|
|
9894
|
-
(tty, sig) => this.
|
|
9895
|
-
|
|
9896
|
-
this.jobs.tcgetpgrp(tty, 0),
|
|
9897
|
-
() => this.jobs.signalOwnedForeground(tty, sig)
|
|
9898
|
-
)
|
|
9935
|
+
(tty, sig) => this.keySignal(tty, 0, sig, () => this.jobs.signalOwnedForeground(tty, sig)),
|
|
9936
|
+
(tty) => this.settling.reading(this.jobs.tcgetpgrp(tty, 0))
|
|
9899
9937
|
);
|
|
9900
9938
|
net = new LoopbackNet();
|
|
9901
9939
|
cdp;
|
|
@@ -10311,6 +10349,11 @@ var Launcher = class {
|
|
|
10311
10349
|
})
|
|
10312
10350
|
);
|
|
10313
10351
|
}
|
|
10352
|
+
keySignal(tty, fallback, sig, send) {
|
|
10353
|
+
const pgid = this.jobs.tcgetpgrp(tty, fallback);
|
|
10354
|
+
const foreground = () => this.jobs.tcgetpgrp(tty, fallback);
|
|
10355
|
+
this.settling.deliver(sig, pgid, send, tty.reading ? void 0 : foreground);
|
|
10356
|
+
}
|
|
10314
10357
|
ignoredBy(pid, fork = false) {
|
|
10315
10358
|
return this.processes.get(pid)?.ignoredSignals(fork) ?? 0;
|
|
10316
10359
|
}
|
|
@@ -10506,12 +10549,9 @@ var Launcher = class {
|
|
|
10506
10549
|
let leader = 0;
|
|
10507
10550
|
const tty = new KernelTty(
|
|
10508
10551
|
{ 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
|
-
)
|
|
10552
|
+
(sig) => this.keySignal(tty, leader, sig, () => this.jobs.signalForeground(tty, leader, sig))
|
|
10514
10553
|
);
|
|
10554
|
+
tty.onRead = () => this.settling.reading(this.jobs.tcgetpgrp(tty, leader));
|
|
10515
10555
|
tty.name = `/dev/tty${++this.terminals}`;
|
|
10516
10556
|
tty.setSize(options.cols ?? 80, options.rows ?? 24);
|
|
10517
10557
|
const fds = new FdTable();
|