@ai-ecoverse/slicc-kernel 1.42.2 → 1.43.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 +1 -0
- package/dist/kernel-worker.js +11 -2
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +86 -13
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +11 -2
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +86 -13
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
|
@@ -3237,10 +3237,12 @@ var init_process_signals = __esm({
|
|
|
3237
3237
|
}
|
|
3238
3238
|
if (!masks) return;
|
|
3239
3239
|
this.restart = masks.restart;
|
|
3240
|
-
const { caught, ignored } = masks;
|
|
3241
|
-
|
|
3240
|
+
const { caught, ignored, defaults = 0 } = masks;
|
|
3241
|
+
const same = caught === this.reported.caught && ignored === this.reported.ignored;
|
|
3242
|
+
if (same && defaults === 0) return;
|
|
3242
3243
|
this.reported = { caught, ignored };
|
|
3243
|
-
|
|
3244
|
+
const req = { op: "sig-mask", caught, ignored, ...defaults ? { defaults } : {} };
|
|
3245
|
+
this.raw.call(req, Number.POSITIVE_INFINITY, "sig-mask");
|
|
3244
3246
|
}
|
|
3245
3247
|
quiet(fn) {
|
|
3246
3248
|
this.quieted++;
|
|
@@ -3518,8 +3520,8 @@ function pidStatus(info) {
|
|
|
3518
3520
|
"SigPnd: 0000000000000000",
|
|
3519
3521
|
"ShdPnd: 0000000000000000",
|
|
3520
3522
|
"SigBlk: 0000000000000000",
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
+
`SigIgn: ${sigMask(info.sigIgn)}`,
|
|
3524
|
+
`SigCgt: ${sigMask(info.sigCgt)}`,
|
|
3523
3525
|
""
|
|
3524
3526
|
].join("\n");
|
|
3525
3527
|
}
|
|
@@ -3724,7 +3726,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
3724
3726
|
readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
|
|
3725
3727
|
};
|
|
3726
3728
|
}
|
|
3727
|
-
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, ESRCH, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES;
|
|
3729
|
+
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, ESRCH, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask;
|
|
3728
3730
|
var init_procfs = __esm({
|
|
3729
3731
|
"src/process/procfs.ts"() {
|
|
3730
3732
|
"use strict";
|
|
@@ -3741,6 +3743,7 @@ var init_procfs = __esm({
|
|
|
3741
3743
|
FALLBACK_MEMORY = 4 * KIB * KIB * KIB;
|
|
3742
3744
|
PID_FILES = ["cmdline", "comm", "stat", "statm", "status"];
|
|
3743
3745
|
SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime"];
|
|
3746
|
+
sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
|
|
3744
3747
|
}
|
|
3745
3748
|
});
|
|
3746
3749
|
|
|
@@ -5480,6 +5483,8 @@ var init_wasi_host = __esm({
|
|
|
5480
5483
|
startCwd;
|
|
5481
5484
|
interruptWakes = false;
|
|
5482
5485
|
onRaise;
|
|
5486
|
+
muted;
|
|
5487
|
+
signals;
|
|
5483
5488
|
listening;
|
|
5484
5489
|
o;
|
|
5485
5490
|
constructor(o) {
|
|
@@ -5561,7 +5566,8 @@ var init_wasi_host = __esm({
|
|
|
5561
5566
|
flags,
|
|
5562
5567
|
data: mem.string(dp, dl)
|
|
5563
5568
|
}),
|
|
5564
|
-
umount2: (tp, tl, flags) => void this.o.kernel.call({ op: "umount", target: path(tp, tl), flags })
|
|
5569
|
+
umount2: (tp, tl, flags) => void this.o.kernel.call({ op: "umount", target: path(tp, tl), flags }),
|
|
5570
|
+
sigaction_set: (sig, disposition, flags) => this.signals ? this.signals.disposition(sig, disposition, flags) : E.NOSYS
|
|
5565
5571
|
});
|
|
5566
5572
|
}
|
|
5567
5573
|
imports() {
|
|
@@ -5828,6 +5834,7 @@ var init_wasi_host = __esm({
|
|
|
5828
5834
|
return this.o.kernel.call({ op: "fd-vfs-stat", fd });
|
|
5829
5835
|
}
|
|
5830
5836
|
write(fd, data) {
|
|
5837
|
+
if (this.muted?.(fd, data)) return data.length;
|
|
5831
5838
|
const e = this.fds.get(fd);
|
|
5832
5839
|
if (e.type === "kernel") {
|
|
5833
5840
|
try {
|
|
@@ -6223,18 +6230,33 @@ var init_wasi_module = __esm({
|
|
|
6223
6230
|
});
|
|
6224
6231
|
|
|
6225
6232
|
// src/process/wasi/wasi-signals.ts
|
|
6226
|
-
var DELIVERED_MASK, WasiSignals;
|
|
6233
|
+
var DELIVERED_MASK, STOP_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
6227
6234
|
var init_wasi_signals = __esm({
|
|
6228
6235
|
"src/process/wasi/wasi-signals.ts"() {
|
|
6229
6236
|
"use strict";
|
|
6230
6237
|
init_signals();
|
|
6238
|
+
init_wasi_abi();
|
|
6239
|
+
init_wasi_host();
|
|
6231
6240
|
DELIVERED_MASK = Object.values(SIG).filter((sig) => sig !== SIG.KILL && sig !== SIG.STOP).reduce((m, sig) => m | sigbit(sig), 0);
|
|
6241
|
+
STOP_DEFAULTS = sigbit(SIG.TSTP) | sigbit(SIG.TTIN) | sigbit(SIG.TTOU);
|
|
6242
|
+
LIBC_DEFAULT_EXIT = 127;
|
|
6243
|
+
SA_RESTART = 268435456;
|
|
6244
|
+
DISPOSITION_IGNORE = 1;
|
|
6245
|
+
DISPOSITION_HANDLER = 2;
|
|
6246
|
+
withBit = (mask, bit, on) => on ? mask | bit : mask & ~bit;
|
|
6247
|
+
WASIX_LIBC_DEFAULT_LINE = /^Program recieved (?:stop|termination|fatal) signal: [^\n]+\n$/;
|
|
6232
6248
|
WasiSignals = class {
|
|
6233
6249
|
exports;
|
|
6234
6250
|
callback;
|
|
6235
6251
|
uncaught = 0;
|
|
6236
6252
|
delivering;
|
|
6237
6253
|
defaulted = false;
|
|
6254
|
+
libcDefault = false;
|
|
6255
|
+
hooked = false;
|
|
6256
|
+
handlers = 0;
|
|
6257
|
+
ignoring = 0;
|
|
6258
|
+
restarting = 0;
|
|
6259
|
+
defaults = 0;
|
|
6238
6260
|
fallBack;
|
|
6239
6261
|
onKilled;
|
|
6240
6262
|
constructor(fallBack, onKilled) {
|
|
@@ -6250,26 +6272,71 @@ var init_wasi_signals = __esm({
|
|
|
6250
6272
|
register(name) {
|
|
6251
6273
|
if (typeof this.exports?.[name] === "function") this.callback = name;
|
|
6252
6274
|
}
|
|
6275
|
+
useHook() {
|
|
6276
|
+
this.hooked = true;
|
|
6277
|
+
}
|
|
6278
|
+
disposition(sig, disposition, flags) {
|
|
6279
|
+
if (sig < 1 || sig > 31 || (DELIVERED_MASK & sigbit(sig)) === 0) return E.INVAL;
|
|
6280
|
+
const bit = sigbit(sig);
|
|
6281
|
+
this.handlers = withBit(this.handlers, bit, disposition === DISPOSITION_HANDLER);
|
|
6282
|
+
this.ignoring = withBit(this.ignoring, bit, disposition === DISPOSITION_IGNORE);
|
|
6283
|
+
this.restarting = withBit(this.restarting, bit, (flags & SA_RESTART) !== 0);
|
|
6284
|
+
this.defaults = withBit(this.defaults, bit, disposition === 0);
|
|
6285
|
+
return E.SUCCESS;
|
|
6286
|
+
}
|
|
6287
|
+
snapshot() {
|
|
6288
|
+
return {
|
|
6289
|
+
...this.callback ? { callback: this.callback } : {},
|
|
6290
|
+
...this.hooked ? { hooked: true } : {},
|
|
6291
|
+
handlers: this.handlers,
|
|
6292
|
+
ignoring: this.ignoring,
|
|
6293
|
+
restarting: this.restarting,
|
|
6294
|
+
uncaught: this.uncaught
|
|
6295
|
+
};
|
|
6296
|
+
}
|
|
6297
|
+
restore(state) {
|
|
6298
|
+
if (state.callback) this.register(state.callback);
|
|
6299
|
+
if (state.hooked) this.hooked = true;
|
|
6300
|
+
this.handlers = state.handlers;
|
|
6301
|
+
this.ignoring = state.ignoring;
|
|
6302
|
+
this.restarting = state.restarting;
|
|
6303
|
+
this.uncaught = state.uncaught;
|
|
6304
|
+
}
|
|
6253
6305
|
masks() {
|
|
6306
|
+
if (this.hooked) {
|
|
6307
|
+
const caught = this.handler() ? this.handlers : 0;
|
|
6308
|
+
const defaults = this.defaults;
|
|
6309
|
+
this.defaults = 0;
|
|
6310
|
+
return { caught, ignored: this.ignoring, restart: this.restarting, defaults };
|
|
6311
|
+
}
|
|
6254
6312
|
if (!this.handler()) return null;
|
|
6255
|
-
return { caught: DELIVERED_MASK & ~this.uncaught, ignored: 0, restart: 0 };
|
|
6313
|
+
return { caught: DELIVERED_MASK & ~this.uncaught & ~STOP_DEFAULTS, ignored: 0, restart: 0 };
|
|
6256
6314
|
}
|
|
6257
6315
|
raise(sig) {
|
|
6258
6316
|
const handler = this.handler();
|
|
6259
6317
|
if (!handler) return;
|
|
6260
|
-
const outer = { sig: this.delivering, defaulted: this.defaulted };
|
|
6318
|
+
const outer = { sig: this.delivering, defaulted: this.defaulted, libc: this.libcDefault };
|
|
6261
6319
|
this.delivering = sig;
|
|
6262
6320
|
this.defaulted = false;
|
|
6321
|
+
this.libcDefault = false;
|
|
6263
6322
|
try {
|
|
6264
6323
|
handler(sig);
|
|
6265
6324
|
} catch (e) {
|
|
6266
|
-
|
|
6325
|
+
const libcExit = e instanceof WasiExit && e.code === LIBC_DEFAULT_EXIT && this.libcDefault;
|
|
6326
|
+
if (!(libcExit && !this.defaulted) && !(e instanceof WebAssembly.RuntimeError)) throw e;
|
|
6267
6327
|
if (!this.defaulted) this.defaultAction(sig);
|
|
6268
6328
|
} finally {
|
|
6269
6329
|
this.delivering = outer.sig;
|
|
6270
6330
|
this.defaulted = outer.defaulted;
|
|
6331
|
+
this.libcDefault = outer.libc;
|
|
6271
6332
|
}
|
|
6272
6333
|
}
|
|
6334
|
+
muted(fd, data) {
|
|
6335
|
+
if (fd !== 2 || this.delivering === void 0) return false;
|
|
6336
|
+
if (!WASIX_LIBC_DEFAULT_LINE.test(new TextDecoder().decode(data))) return false;
|
|
6337
|
+
this.libcDefault = true;
|
|
6338
|
+
return true;
|
|
6339
|
+
}
|
|
6273
6340
|
raised(sig) {
|
|
6274
6341
|
if (sig !== SIG.ABRT || this.delivering === void 0) return false;
|
|
6275
6342
|
if (!this.defaulted) this.defaultAction(this.delivering);
|
|
@@ -7085,7 +7152,8 @@ var init_wasix_process = __esm({
|
|
|
7085
7152
|
cloexec: [...fds.cloexec],
|
|
7086
7153
|
cwd: this.host.cwd,
|
|
7087
7154
|
...fds.isShared ? { shared: true } : {},
|
|
7088
|
-
setjmps: this.driver.setjmps()
|
|
7155
|
+
setjmps: this.driver.setjmps(),
|
|
7156
|
+
...this.host.signals ? { signals: this.host.signals.snapshot() } : {}
|
|
7089
7157
|
};
|
|
7090
7158
|
return this.call({
|
|
7091
7159
|
op: "proc-fork",
|
|
@@ -8118,7 +8186,11 @@ async function runWasiProcess(init, port3) {
|
|
|
8118
8186
|
main.memory = memoryOf(instance, memory);
|
|
8119
8187
|
publishMemory(init.sab, sizeOf(main)());
|
|
8120
8188
|
signals.bind(instance.exports);
|
|
8189
|
+
if (importsSigactionHook(module)) signals.useHook();
|
|
8190
|
+
if (fork?.signals) signals.restore(fork.signals);
|
|
8191
|
+
host.signals = signals;
|
|
8121
8192
|
host.onRaise = (sig) => signals.raised(sig);
|
|
8193
|
+
host.muted = (fd, data) => signals.muted(fd, data);
|
|
8122
8194
|
const exports = instance.exports;
|
|
8123
8195
|
driver.bind(instance.exports);
|
|
8124
8196
|
try {
|
|
@@ -8213,7 +8285,7 @@ async function runWasiThread(init, port3) {
|
|
|
8213
8285
|
throw e;
|
|
8214
8286
|
}
|
|
8215
8287
|
}
|
|
8216
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC, SLICC_FS, RESERVED2, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
8288
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, SLICC_FS, RESERVED2, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
8217
8289
|
var init_wasi_runtime = __esm({
|
|
8218
8290
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
8219
8291
|
"use strict";
|
|
@@ -8242,6 +8314,7 @@ var init_wasi_runtime = __esm({
|
|
|
8242
8314
|
SLICC = "slicc";
|
|
8243
8315
|
SLICC_FS = "slicc_fs";
|
|
8244
8316
|
RESERVED2 = RESERVED_NAMESPACES;
|
|
8317
|
+
importsSigactionHook = (module) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === "sigaction_set");
|
|
8245
8318
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
8246
8319
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
8247
8320
|
LinkSync = class {
|