@ai-ecoverse/slicc-kernel 1.29.0 → 1.29.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 +2 -2
- package/dist/kernel-worker.js +54 -1
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +22 -7
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +54 -1
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +22 -7
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -7450,6 +7450,7 @@ var SYSCALL_OPS = /* @__PURE__ */ new Set([
|
|
|
7450
7450
|
"mount",
|
|
7451
7451
|
"umount",
|
|
7452
7452
|
"proc-exec",
|
|
7453
|
+
"proc-identity",
|
|
7453
7454
|
"proc-setpgid",
|
|
7454
7455
|
"proc-getpgid",
|
|
7455
7456
|
"proc-getsid",
|
|
@@ -7549,6 +7550,7 @@ var WasmProcess = class {
|
|
|
7549
7550
|
for (const listener of this.stateListeners) listener("continued", SIG.CONT);
|
|
7550
7551
|
}
|
|
7551
7552
|
async syscall(req) {
|
|
7553
|
+
this.options.onSyscall?.();
|
|
7552
7554
|
for (; ; ) {
|
|
7553
7555
|
await this.resumed;
|
|
7554
7556
|
const stops = this.stops;
|
|
@@ -7894,6 +7896,8 @@ var WasmProcess = class {
|
|
|
7894
7896
|
const waited = await this.children.wait(req.pid, req.nohang, signal, flags);
|
|
7895
7897
|
return { ok: true, kind: "json", json: waited };
|
|
7896
7898
|
}
|
|
7899
|
+
case "proc-identity":
|
|
7900
|
+
return { ok: true, kind: "json", json: await this.options.identity?.() ?? null };
|
|
7897
7901
|
case "proc-exec": {
|
|
7898
7902
|
this.execChild = req.pid;
|
|
7899
7903
|
this.options.jobs?.exec(this.pid, req.pid);
|
|
@@ -8044,6 +8048,8 @@ function spawnWasmProcess(opts) {
|
|
|
8044
8048
|
const header3 = new Int32Array(sab, 0, SAB_HEADER_I32);
|
|
8045
8049
|
const process = new WasmProcess(opts.pid, opts.fds, {
|
|
8046
8050
|
...opts.ignored ? { ignored: opts.ignored } : {},
|
|
8051
|
+
...opts.identity ? { identity: opts.identity } : {},
|
|
8052
|
+
...opts.onSyscall ? { onSyscall: opts.onSyscall } : {},
|
|
8047
8053
|
spawner: opts.spawner,
|
|
8048
8054
|
forker: opts.forker,
|
|
8049
8055
|
fs: opts.fs,
|
|
@@ -9525,6 +9531,7 @@ var ENV_REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
|
9525
9531
|
var WASM_MAGIC = [0, 97, 115, 109];
|
|
9526
9532
|
var SHEBANG_MAX = 256;
|
|
9527
9533
|
var NOT_FOUND = 127;
|
|
9534
|
+
var DECIDE_MS = 100;
|
|
9528
9535
|
var INIT_PID = 1;
|
|
9529
9536
|
var SHARED_DIRS = ["/tmp", "/home"];
|
|
9530
9537
|
var encoder3 = new TextEncoder();
|
|
@@ -9623,6 +9630,8 @@ var Launcher = class {
|
|
|
9623
9630
|
fstabRetries;
|
|
9624
9631
|
inserted = /* @__PURE__ */ new Map();
|
|
9625
9632
|
openFiles = /* @__PURE__ */ new Set();
|
|
9633
|
+
deciding = /* @__PURE__ */ new Map();
|
|
9634
|
+
identities = { asked: 0, timedOut: 0 };
|
|
9626
9635
|
nodes;
|
|
9627
9636
|
held = /* @__PURE__ */ new Set();
|
|
9628
9637
|
processMounts;
|
|
@@ -9829,8 +9838,19 @@ var Launcher = class {
|
|
|
9829
9838
|
}
|
|
9830
9839
|
const pid = this.nextPid++;
|
|
9831
9840
|
const terminal = req.fds.stdioTerminal();
|
|
9841
|
+
const decided = req.decided ?? Promise.resolve(true);
|
|
9842
|
+
const count = (byParent) => {
|
|
9843
|
+
this.identities.asked++;
|
|
9844
|
+
if (!byParent) this.identities.timedOut++;
|
|
9845
|
+
};
|
|
9846
|
+
let asked;
|
|
9832
9847
|
const handle = spawnWasmProcess({
|
|
9833
9848
|
pid,
|
|
9849
|
+
identity: async () => {
|
|
9850
|
+
await (asked ??= decided.then(count));
|
|
9851
|
+
return this.identityOf(pid);
|
|
9852
|
+
},
|
|
9853
|
+
onSyscall: () => this.decide(pid),
|
|
9834
9854
|
...req.ignored ? { ignored: req.ignored } : {},
|
|
9835
9855
|
program: req.program,
|
|
9836
9856
|
argv0: req.argv0,
|
|
@@ -9903,7 +9923,8 @@ var Launcher = class {
|
|
|
9903
9923
|
};
|
|
9904
9924
|
const shown = (pid) => {
|
|
9905
9925
|
const member = pid === void 0 ? void 0 : members.get(pid);
|
|
9906
|
-
|
|
9926
|
+
const root = member && rootOf(member).pid;
|
|
9927
|
+
return root !== void 0 && this.running(root) ? root : INIT_PID;
|
|
9907
9928
|
};
|
|
9908
9929
|
const listed = [];
|
|
9909
9930
|
for (const member of members.values()) {
|
|
@@ -9932,7 +9953,9 @@ var Launcher = class {
|
|
|
9932
9953
|
throw new SpawnError(await this.unrunnable(req.file, req.cwd));
|
|
9933
9954
|
}
|
|
9934
9955
|
const exec = req.exec ? { exec: true } : {};
|
|
9956
|
+
const deciding = req.exec ? void 0 : this.undecided(ppid);
|
|
9935
9957
|
const handle = await this.launch(planned, {
|
|
9958
|
+
...deciding ? { decided: deciding.promise } : {},
|
|
9936
9959
|
env: req.env,
|
|
9937
9960
|
cwd: req.cwd,
|
|
9938
9961
|
fds,
|
|
@@ -9941,9 +9964,39 @@ var Launcher = class {
|
|
|
9941
9964
|
ignored: this.ignoredBy(ppid),
|
|
9942
9965
|
...exec
|
|
9943
9966
|
});
|
|
9967
|
+
deciding?.attach();
|
|
9944
9968
|
return childHandle(handle);
|
|
9945
9969
|
};
|
|
9946
9970
|
}
|
|
9971
|
+
undecided(ppid) {
|
|
9972
|
+
const decided = Promise.withResolvers();
|
|
9973
|
+
return {
|
|
9974
|
+
promise: decided.promise,
|
|
9975
|
+
attach: () => {
|
|
9976
|
+
const timer = setTimeout(() => decided.resolve(false), DECIDE_MS);
|
|
9977
|
+
void decided.promise.then(() => clearTimeout(timer));
|
|
9978
|
+
const waiting = this.deciding.get(ppid) ?? /* @__PURE__ */ new Set();
|
|
9979
|
+
waiting.add(decided.resolve);
|
|
9980
|
+
this.deciding.set(ppid, waiting);
|
|
9981
|
+
}
|
|
9982
|
+
};
|
|
9983
|
+
}
|
|
9984
|
+
identityOf(pid) {
|
|
9985
|
+
const parent = this.jobs.shownParent(pid);
|
|
9986
|
+
const alive = parent !== void 0 && this.running(parent);
|
|
9987
|
+
return { pid: this.jobs.shown(pid), ppid: alive ? parent : INIT_PID };
|
|
9988
|
+
}
|
|
9989
|
+
running(shown) {
|
|
9990
|
+
return this.jobs.list().some((member) => !this.zombies.has(member.pid) && this.jobs.shown(member.pid) === shown);
|
|
9991
|
+
}
|
|
9992
|
+
decide(ppid) {
|
|
9993
|
+
const waiting = this.deciding.get(ppid);
|
|
9994
|
+
if (!waiting) return;
|
|
9995
|
+
this.deciding.delete(ppid);
|
|
9996
|
+
setTimeout(() => {
|
|
9997
|
+
for (const resolve of waiting) resolve(true);
|
|
9998
|
+
}, 0);
|
|
9999
|
+
}
|
|
9947
10000
|
forker(ppid, parent) {
|
|
9948
10001
|
const { exec: _exec, ...image } = parent;
|
|
9949
10002
|
return async (state, fds) => childHandle(
|