@ai-ecoverse/slicc-kernel 1.71.1 → 1.73.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 +21 -6
- package/dist/index.js +42 -3
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +470 -51
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +37 -6
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +432 -48
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +37 -6
- package/dist/process-worker.js.map +2 -2
- package/package.json +4 -3
|
@@ -3879,6 +3879,11 @@ var init_js_kernel = __esm({
|
|
|
3879
3879
|
freeze() {
|
|
3880
3880
|
while (Atomics.load(this.header, SAB_I_STOP) === 1) Atomics.wait(this.header, SAB_I_STOP, 1);
|
|
3881
3881
|
}
|
|
3882
|
+
disposition(sig) {
|
|
3883
|
+
if (this.handlers.has(sig)) return "caught";
|
|
3884
|
+
if (this.ignored & sigbit(sig)) return "ignored";
|
|
3885
|
+
return defaultAction(sig);
|
|
3886
|
+
}
|
|
3882
3887
|
setHandler(sig, handler) {
|
|
3883
3888
|
if (sig === SIG.KILL || sig === SIG.STOP) {
|
|
3884
3889
|
return Promise.reject(new JsCallError("EINVAL", "signal"));
|
|
@@ -4532,7 +4537,7 @@ function settled(lane, writes) {
|
|
|
4532
4537
|
});
|
|
4533
4538
|
return out;
|
|
4534
4539
|
}
|
|
4535
|
-
function exitAtOnce(lane, writes, modes, status2) {
|
|
4540
|
+
function exitAtOnce(lane, writes, modes, status2, last = { op: "proc-exit", status: status2 & 255 }) {
|
|
4536
4541
|
const done = settled(lane, writes);
|
|
4537
4542
|
const broken = /* @__PURE__ */ new Set();
|
|
4538
4543
|
for (const w of writes) {
|
|
@@ -4542,7 +4547,7 @@ function exitAtOnce(lane, writes, modes, status2) {
|
|
|
4542
4547
|
if (!writeOut(lane, w.fd, w.data.subarray(w.at + (sent ?? 0)))) broken.add(w.fd);
|
|
4543
4548
|
}
|
|
4544
4549
|
for (const mode of modes) restoreMode(lane, mode);
|
|
4545
|
-
lane(
|
|
4550
|
+
lane(last);
|
|
4546
4551
|
const parked = new Int32Array(new SharedArrayBuffer(4));
|
|
4547
4552
|
for (; ; ) Atomics.wait(parked, 0, 0);
|
|
4548
4553
|
}
|
|
@@ -5360,7 +5365,7 @@ var init_sync_sab_bridge = __esm({
|
|
|
5360
5365
|
|
|
5361
5366
|
// src/process/js/js-sync.ts
|
|
5362
5367
|
function laneOf(lane) {
|
|
5363
|
-
if (!lane) return
|
|
5368
|
+
if (!lane) return noLane;
|
|
5364
5369
|
const transport = createSyncSabTransport(lane.sab, lane.port);
|
|
5365
5370
|
return (req) => transport.call(req, Number.POSITIVE_INFINITY, req.op);
|
|
5366
5371
|
}
|
|
@@ -5561,7 +5566,7 @@ function syncPathOps(kernel, resolve, statOf, open) {
|
|
|
5561
5566
|
}
|
|
5562
5567
|
};
|
|
5563
5568
|
}
|
|
5564
|
-
var encoder3, JsSyncKernel;
|
|
5569
|
+
var encoder3, noLane, JsSyncKernel;
|
|
5565
5570
|
var init_js_sync = __esm({
|
|
5566
5571
|
"src/process/js/js-sync.ts"() {
|
|
5567
5572
|
"use strict";
|
|
@@ -5572,6 +5577,7 @@ var init_js_sync = __esm({
|
|
|
5572
5577
|
init_js_io();
|
|
5573
5578
|
init_js_kernel();
|
|
5574
5579
|
encoder3 = new TextEncoder();
|
|
5580
|
+
noLane = () => ({ ok: false, errno: "ENOSYS", message: "no sync lane" });
|
|
5575
5581
|
JsSyncKernel = class {
|
|
5576
5582
|
lane;
|
|
5577
5583
|
kernel;
|
|
@@ -5886,6 +5892,30 @@ function resolvePath(cwd, path) {
|
|
|
5886
5892
|
}
|
|
5887
5893
|
return `/${parts.join("/")}`;
|
|
5888
5894
|
}
|
|
5895
|
+
function killer(d) {
|
|
5896
|
+
return (pid, signal = "SIGTERM") => {
|
|
5897
|
+
const sig = signal === 0 ? 0 : signalNumber(signal);
|
|
5898
|
+
const self = sig !== 0 && includesSelf(d.syncKernel, d.self, pid);
|
|
5899
|
+
if (!self || d.kernel.disposition(sig) !== "terminate") {
|
|
5900
|
+
d.syncKernel.call({ op: "proc-kill", pid, sig });
|
|
5901
|
+
return;
|
|
5902
|
+
}
|
|
5903
|
+
const target = pid === d.self ? {} : { target: pid };
|
|
5904
|
+
const r = d.lane({ op: "proc-kill-self", sig, ...target, probe: true });
|
|
5905
|
+
if (!r.ok) throw new JsCallError(r.errno, "kill");
|
|
5906
|
+
if (r.kind === "void") return;
|
|
5907
|
+
exitAtOnce(d.lane, [...d.writes], d.modes(), 128 + sig, {
|
|
5908
|
+
op: "proc-kill-self",
|
|
5909
|
+
sig,
|
|
5910
|
+
...target
|
|
5911
|
+
});
|
|
5912
|
+
};
|
|
5913
|
+
}
|
|
5914
|
+
function includesSelf(kernel, self, pid) {
|
|
5915
|
+
if (pid === self || pid === 0) return true;
|
|
5916
|
+
if (pid > 0 || pid === -1) return false;
|
|
5917
|
+
return kernel.json({ op: "proc-getpgid", pid: 0 }) === -pid;
|
|
5918
|
+
}
|
|
5889
5919
|
function writer(kernel, info, pid) {
|
|
5890
5920
|
const writes = /* @__PURE__ */ new Set();
|
|
5891
5921
|
const sendAll = async (fd, data, i, w, signal) => {
|
|
@@ -5997,7 +6027,7 @@ function createContext(o) {
|
|
|
5997
6027
|
};
|
|
5998
6028
|
const fs = pathOps(kernel, resolve, statOf, open);
|
|
5999
6029
|
const lane = o.lane ?? laneOf(void 0);
|
|
6000
|
-
if (o.lane) kernel.syncLane = o.lane;
|
|
6030
|
+
if (o.lane && o.lane !== noLane) kernel.syncLane = o.lane;
|
|
6001
6031
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
6002
6032
|
const terminal = ttyOps(kernel);
|
|
6003
6033
|
const sync = {
|
|
@@ -6006,7 +6036,8 @@ function createContext(o) {
|
|
|
6006
6036
|
exit: (status2 = 0) => {
|
|
6007
6037
|
exiting ??= status2 & 255;
|
|
6008
6038
|
return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
|
|
6009
|
-
}
|
|
6039
|
+
},
|
|
6040
|
+
kill: killer({ self: o.pid, kernel, syncKernel, lane, writes, modes: terminal.modes })
|
|
6010
6041
|
};
|
|
6011
6042
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
6012
6043
|
const children = childOps(kernel, io, { env: o.env, cwd: o.cwd, signal: signalNumber });
|