@ai-ecoverse/slicc-kernel 1.71.1 → 1.72.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 +18 -3
- package/dist/index.js +29 -0
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +392 -36
- 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 +359 -34
- 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
package/dist/process-worker.js
CHANGED
|
@@ -10955,6 +10955,11 @@ var init_js_kernel = __esm({
|
|
|
10955
10955
|
freeze() {
|
|
10956
10956
|
while (Atomics.load(this.header, SAB_I_STOP) === 1) Atomics.wait(this.header, SAB_I_STOP, 1);
|
|
10957
10957
|
}
|
|
10958
|
+
disposition(sig) {
|
|
10959
|
+
if (this.handlers.has(sig)) return "caught";
|
|
10960
|
+
if (this.ignored & sigbit(sig)) return "ignored";
|
|
10961
|
+
return defaultAction(sig);
|
|
10962
|
+
}
|
|
10958
10963
|
setHandler(sig, handler) {
|
|
10959
10964
|
if (sig === SIG.KILL || sig === SIG.STOP) {
|
|
10960
10965
|
return Promise.reject(new JsCallError("EINVAL", "signal"));
|
|
@@ -11608,7 +11613,7 @@ function settled(lane, writes) {
|
|
|
11608
11613
|
});
|
|
11609
11614
|
return out;
|
|
11610
11615
|
}
|
|
11611
|
-
function exitAtOnce(lane, writes, modes, status2) {
|
|
11616
|
+
function exitAtOnce(lane, writes, modes, status2, last = { op: "proc-exit", status: status2 & 255 }) {
|
|
11612
11617
|
const done = settled(lane, writes);
|
|
11613
11618
|
const broken = /* @__PURE__ */ new Set();
|
|
11614
11619
|
for (const w of writes) {
|
|
@@ -11618,7 +11623,7 @@ function exitAtOnce(lane, writes, modes, status2) {
|
|
|
11618
11623
|
if (!writeOut(lane, w.fd, w.data.subarray(w.at + (sent ?? 0)))) broken.add(w.fd);
|
|
11619
11624
|
}
|
|
11620
11625
|
for (const mode of modes) restoreMode(lane, mode);
|
|
11621
|
-
lane(
|
|
11626
|
+
lane(last);
|
|
11622
11627
|
const parked = new Int32Array(new SharedArrayBuffer(4));
|
|
11623
11628
|
for (; ; ) Atomics.wait(parked, 0, 0);
|
|
11624
11629
|
}
|
|
@@ -12185,7 +12190,7 @@ var init_js_run = __esm({
|
|
|
12185
12190
|
|
|
12186
12191
|
// src/process/js/js-sync.ts
|
|
12187
12192
|
function laneOf(lane) {
|
|
12188
|
-
if (!lane) return
|
|
12193
|
+
if (!lane) return noLane;
|
|
12189
12194
|
const transport = createSyncSabTransport(lane.sab, lane.port);
|
|
12190
12195
|
return (req) => transport.call(req, Number.POSITIVE_INFINITY, req.op);
|
|
12191
12196
|
}
|
|
@@ -12386,7 +12391,7 @@ function syncPathOps(kernel, resolve, statOf, open) {
|
|
|
12386
12391
|
}
|
|
12387
12392
|
};
|
|
12388
12393
|
}
|
|
12389
|
-
var encoder3, JsSyncKernel;
|
|
12394
|
+
var encoder3, noLane, JsSyncKernel;
|
|
12390
12395
|
var init_js_sync = __esm({
|
|
12391
12396
|
"src/process/js/js-sync.ts"() {
|
|
12392
12397
|
"use strict";
|
|
@@ -12397,6 +12402,7 @@ var init_js_sync = __esm({
|
|
|
12397
12402
|
init_js_io();
|
|
12398
12403
|
init_js_kernel();
|
|
12399
12404
|
encoder3 = new TextEncoder();
|
|
12405
|
+
noLane = () => ({ ok: false, errno: "ENOSYS", message: "no sync lane" });
|
|
12400
12406
|
JsSyncKernel = class {
|
|
12401
12407
|
lane;
|
|
12402
12408
|
kernel;
|
|
@@ -12711,6 +12717,30 @@ function resolvePath(cwd, path) {
|
|
|
12711
12717
|
}
|
|
12712
12718
|
return `/${parts.join("/")}`;
|
|
12713
12719
|
}
|
|
12720
|
+
function killer(d) {
|
|
12721
|
+
return (pid, signal = "SIGTERM") => {
|
|
12722
|
+
const sig = signal === 0 ? 0 : signalNumber(signal);
|
|
12723
|
+
const self = sig !== 0 && includesSelf(d.syncKernel, d.self, pid);
|
|
12724
|
+
if (!self || d.kernel.disposition(sig) !== "terminate") {
|
|
12725
|
+
d.syncKernel.call({ op: "proc-kill", pid, sig });
|
|
12726
|
+
return;
|
|
12727
|
+
}
|
|
12728
|
+
const target = pid === d.self ? {} : { target: pid };
|
|
12729
|
+
const r = d.lane({ op: "proc-kill-self", sig, ...target, probe: true });
|
|
12730
|
+
if (!r.ok) throw new JsCallError(r.errno, "kill");
|
|
12731
|
+
if (r.kind === "void") return;
|
|
12732
|
+
exitAtOnce(d.lane, [...d.writes], d.modes(), 128 + sig, {
|
|
12733
|
+
op: "proc-kill-self",
|
|
12734
|
+
sig,
|
|
12735
|
+
...target
|
|
12736
|
+
});
|
|
12737
|
+
};
|
|
12738
|
+
}
|
|
12739
|
+
function includesSelf(kernel, self, pid) {
|
|
12740
|
+
if (pid === self || pid === 0) return true;
|
|
12741
|
+
if (pid > 0 || pid === -1) return false;
|
|
12742
|
+
return kernel.json({ op: "proc-getpgid", pid: 0 }) === -pid;
|
|
12743
|
+
}
|
|
12714
12744
|
function writer(kernel, info, pid) {
|
|
12715
12745
|
const writes = /* @__PURE__ */ new Set();
|
|
12716
12746
|
const sendAll = async (fd, data, i, w, signal) => {
|
|
@@ -12822,7 +12852,7 @@ function createContext(o) {
|
|
|
12822
12852
|
};
|
|
12823
12853
|
const fs = pathOps(kernel, resolve, statOf, open);
|
|
12824
12854
|
const lane = o.lane ?? laneOf(void 0);
|
|
12825
|
-
if (o.lane) kernel.syncLane = o.lane;
|
|
12855
|
+
if (o.lane && o.lane !== noLane) kernel.syncLane = o.lane;
|
|
12826
12856
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
12827
12857
|
const terminal = ttyOps(kernel);
|
|
12828
12858
|
const sync = {
|
|
@@ -12831,7 +12861,8 @@ function createContext(o) {
|
|
|
12831
12861
|
exit: (status2 = 0) => {
|
|
12832
12862
|
exiting ??= status2 & 255;
|
|
12833
12863
|
return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
|
|
12834
|
-
}
|
|
12864
|
+
},
|
|
12865
|
+
kill: killer({ self: o.pid, kernel, syncKernel, lane, writes, modes: terminal.modes })
|
|
12835
12866
|
};
|
|
12836
12867
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
12837
12868
|
const children = childOps(kernel, io, { env: o.env, cwd: o.cwd, signal: signalNumber });
|