@ai-ecoverse/slicc-kernel 1.28.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 +3 -3
- package/dist/kernel-worker.js +62 -3
- 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 +62 -3
- 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 +3 -3
package/dist/node.js
CHANGED
|
@@ -3059,6 +3059,7 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
|
|
|
3059
3059
|
glue,
|
|
3060
3060
|
wasm,
|
|
3061
3061
|
argv0,
|
|
3062
|
+
...raw.argv0Path === true ? { argv0Path: true } : {},
|
|
3062
3063
|
...args ? { args } : {},
|
|
3063
3064
|
...withEnv,
|
|
3064
3065
|
...imports ? { imports } : {}
|
|
@@ -7449,6 +7450,7 @@ var SYSCALL_OPS = /* @__PURE__ */ new Set([
|
|
|
7449
7450
|
"mount",
|
|
7450
7451
|
"umount",
|
|
7451
7452
|
"proc-exec",
|
|
7453
|
+
"proc-identity",
|
|
7452
7454
|
"proc-setpgid",
|
|
7453
7455
|
"proc-getpgid",
|
|
7454
7456
|
"proc-getsid",
|
|
@@ -7548,6 +7550,7 @@ var WasmProcess = class {
|
|
|
7548
7550
|
for (const listener of this.stateListeners) listener("continued", SIG.CONT);
|
|
7549
7551
|
}
|
|
7550
7552
|
async syscall(req) {
|
|
7553
|
+
this.options.onSyscall?.();
|
|
7551
7554
|
for (; ; ) {
|
|
7552
7555
|
await this.resumed;
|
|
7553
7556
|
const stops = this.stops;
|
|
@@ -7893,6 +7896,8 @@ var WasmProcess = class {
|
|
|
7893
7896
|
const waited = await this.children.wait(req.pid, req.nohang, signal, flags);
|
|
7894
7897
|
return { ok: true, kind: "json", json: waited };
|
|
7895
7898
|
}
|
|
7899
|
+
case "proc-identity":
|
|
7900
|
+
return { ok: true, kind: "json", json: await this.options.identity?.() ?? null };
|
|
7896
7901
|
case "proc-exec": {
|
|
7897
7902
|
this.execChild = req.pid;
|
|
7898
7903
|
this.options.jobs?.exec(this.pid, req.pid);
|
|
@@ -8043,6 +8048,8 @@ function spawnWasmProcess(opts) {
|
|
|
8043
8048
|
const header3 = new Int32Array(sab, 0, SAB_HEADER_I32);
|
|
8044
8049
|
const process = new WasmProcess(opts.pid, opts.fds, {
|
|
8045
8050
|
...opts.ignored ? { ignored: opts.ignored } : {},
|
|
8051
|
+
...opts.identity ? { identity: opts.identity } : {},
|
|
8052
|
+
...opts.onSyscall ? { onSyscall: opts.onSyscall } : {},
|
|
8046
8053
|
spawner: opts.spawner,
|
|
8047
8054
|
forker: opts.forker,
|
|
8048
8055
|
fs: opts.fs,
|
|
@@ -9524,6 +9531,7 @@ var ENV_REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
|
9524
9531
|
var WASM_MAGIC = [0, 97, 115, 109];
|
|
9525
9532
|
var SHEBANG_MAX = 256;
|
|
9526
9533
|
var NOT_FOUND = 127;
|
|
9534
|
+
var DECIDE_MS = 100;
|
|
9527
9535
|
var INIT_PID = 1;
|
|
9528
9536
|
var SHARED_DIRS = ["/tmp", "/home"];
|
|
9529
9537
|
var encoder3 = new TextEncoder();
|
|
@@ -9622,6 +9630,8 @@ var Launcher = class {
|
|
|
9622
9630
|
fstabRetries;
|
|
9623
9631
|
inserted = /* @__PURE__ */ new Map();
|
|
9624
9632
|
openFiles = /* @__PURE__ */ new Set();
|
|
9633
|
+
deciding = /* @__PURE__ */ new Map();
|
|
9634
|
+
identities = { asked: 0, timedOut: 0 };
|
|
9625
9635
|
nodes;
|
|
9626
9636
|
held = /* @__PURE__ */ new Set();
|
|
9627
9637
|
processMounts;
|
|
@@ -9685,9 +9695,14 @@ var Launcher = class {
|
|
|
9685
9695
|
const command = (await this.commands()).get(name2);
|
|
9686
9696
|
return command && !command.script ? targetOf(command) : void 0;
|
|
9687
9697
|
}
|
|
9688
|
-
const
|
|
9698
|
+
const path = this.fs.resolvePath(cwd, file);
|
|
9699
|
+
const glue = await followLinks(this.base, path);
|
|
9689
9700
|
const linked = COMMAND2.exec(glue)?.[1];
|
|
9690
|
-
if (linked !== void 0)
|
|
9701
|
+
if (linked !== void 0) {
|
|
9702
|
+
const target = await this.resolve(`/bin/${linked}`, argv0, cwd);
|
|
9703
|
+
const byPath = !COMMAND2.test(path) && (await this.commands()).get(linked)?.argv0Path === true;
|
|
9704
|
+
return target && byPath ? { ...target, argv0: path } : target;
|
|
9705
|
+
}
|
|
9691
9706
|
const head = await this.head(glue);
|
|
9692
9707
|
if (!head) return void 0;
|
|
9693
9708
|
if (isWasm(head)) {
|
|
@@ -9823,8 +9838,19 @@ var Launcher = class {
|
|
|
9823
9838
|
}
|
|
9824
9839
|
const pid = this.nextPid++;
|
|
9825
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;
|
|
9826
9847
|
const handle = spawnWasmProcess({
|
|
9827
9848
|
pid,
|
|
9849
|
+
identity: async () => {
|
|
9850
|
+
await (asked ??= decided.then(count));
|
|
9851
|
+
return this.identityOf(pid);
|
|
9852
|
+
},
|
|
9853
|
+
onSyscall: () => this.decide(pid),
|
|
9828
9854
|
...req.ignored ? { ignored: req.ignored } : {},
|
|
9829
9855
|
program: req.program,
|
|
9830
9856
|
argv0: req.argv0,
|
|
@@ -9897,7 +9923,8 @@ var Launcher = class {
|
|
|
9897
9923
|
};
|
|
9898
9924
|
const shown = (pid) => {
|
|
9899
9925
|
const member = pid === void 0 ? void 0 : members.get(pid);
|
|
9900
|
-
|
|
9926
|
+
const root = member && rootOf(member).pid;
|
|
9927
|
+
return root !== void 0 && this.running(root) ? root : INIT_PID;
|
|
9901
9928
|
};
|
|
9902
9929
|
const listed = [];
|
|
9903
9930
|
for (const member of members.values()) {
|
|
@@ -9926,7 +9953,9 @@ var Launcher = class {
|
|
|
9926
9953
|
throw new SpawnError(await this.unrunnable(req.file, req.cwd));
|
|
9927
9954
|
}
|
|
9928
9955
|
const exec = req.exec ? { exec: true } : {};
|
|
9956
|
+
const deciding = req.exec ? void 0 : this.undecided(ppid);
|
|
9929
9957
|
const handle = await this.launch(planned, {
|
|
9958
|
+
...deciding ? { decided: deciding.promise } : {},
|
|
9930
9959
|
env: req.env,
|
|
9931
9960
|
cwd: req.cwd,
|
|
9932
9961
|
fds,
|
|
@@ -9935,9 +9964,39 @@ var Launcher = class {
|
|
|
9935
9964
|
ignored: this.ignoredBy(ppid),
|
|
9936
9965
|
...exec
|
|
9937
9966
|
});
|
|
9967
|
+
deciding?.attach();
|
|
9938
9968
|
return childHandle(handle);
|
|
9939
9969
|
};
|
|
9940
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
|
+
}
|
|
9941
10000
|
forker(ppid, parent) {
|
|
9942
10001
|
const { exec: _exec, ...image } = parent;
|
|
9943
10002
|
return async (state, fds) => childHandle(
|