@ai-ecoverse/slicc-kernel 1.86.0 → 1.88.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 -11
- package/dist/index.js +1 -0
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +333 -92
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js +6 -8
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.js +284 -84
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +327 -84
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +284 -84
- package/dist/process-worker.js.map +4 -4
- package/package.json +2 -2
package/dist/process-worker.js
CHANGED
|
@@ -144,11 +144,11 @@ function sabViews(sab) {
|
|
|
144
144
|
window: new Uint8Array(sab, SAB_HEADER_BYTES)
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
var SAB_HEADER_I32, SAB_CLOCK_OFFSET, SAB_CLOCK_I64, SAB_HEADER_BYTES, SAB_I_STATE, SAB_I_SEQ, SAB_I_STATUS, SAB_I_TOTAL, SAB_I_CHUNK, SAB_I_OFFSET, SAB_I_REQ, SAB_I_PUB, SAB_I_SIGNALS, SAB_I_TIMERS, SAB_I_MEMORY, SAB_I_TOTAL_HI, SAB_I_OFFSET_HI, SAB_I_KILLED, SAB_I_ASYNC, SAB_I_STOP, U32, SAB_STATE_IDLE, SAB_STATE_PENDING, SAB_STATE_READY, SAB_STATUS_BYTES, SAB_STATUS_JSON, SAB_STATUS_VOID, SAB_STATUS_ERRNO, SAB_DEFAULT_WINDOW_BYTES, SAB_MIN_BYTES, SYNC_SAB_REQ_MSG, SYNC_SAB_NEXT_MSG, encoder, decoder;
|
|
147
|
+
var SAB_HEADER_I32, SAB_CLOCK_OFFSET, SAB_CLOCK_I64, SAB_HEADER_BYTES, SAB_I_STATE, SAB_I_SEQ, SAB_I_STATUS, SAB_I_TOTAL, SAB_I_CHUNK, SAB_I_OFFSET, SAB_I_REQ, SAB_I_PUB, SAB_I_SIGNALS, SAB_I_TIMERS, SAB_I_MEMORY, SAB_I_TOTAL_HI, SAB_I_OFFSET_HI, SAB_I_KILLED, SAB_I_ASYNC, SAB_I_STOP, SAB_I_BLOCKED, U32, SAB_STATE_IDLE, SAB_STATE_PENDING, SAB_STATE_READY, SAB_STATUS_BYTES, SAB_STATUS_JSON, SAB_STATUS_VOID, SAB_STATUS_ERRNO, SAB_DEFAULT_WINDOW_BYTES, SAB_MIN_BYTES, SYNC_SAB_REQ_MSG, SYNC_SAB_NEXT_MSG, encoder, decoder;
|
|
148
148
|
var init_sync_sab_wire = __esm({
|
|
149
149
|
"src/realm/sync-sab-wire.ts"() {
|
|
150
150
|
"use strict";
|
|
151
|
-
SAB_HEADER_I32 =
|
|
151
|
+
SAB_HEADER_I32 = 18;
|
|
152
152
|
SAB_CLOCK_OFFSET = SAB_HEADER_I32 * 4;
|
|
153
153
|
SAB_CLOCK_I64 = 3;
|
|
154
154
|
SAB_HEADER_BYTES = SAB_CLOCK_OFFSET + SAB_CLOCK_I64 * 8;
|
|
@@ -168,6 +168,7 @@ var init_sync_sab_wire = __esm({
|
|
|
168
168
|
SAB_I_KILLED = 13;
|
|
169
169
|
SAB_I_ASYNC = 14;
|
|
170
170
|
SAB_I_STOP = 15;
|
|
171
|
+
SAB_I_BLOCKED = 16;
|
|
171
172
|
U32 = 2 ** 32;
|
|
172
173
|
SAB_STATE_IDLE = 0;
|
|
173
174
|
SAB_STATE_PENDING = 1;
|
|
@@ -2378,7 +2379,7 @@ var init_kernel_streams = __esm({
|
|
|
2378
2379
|
openSealed(open, path, flags, mode) {
|
|
2379
2380
|
const { openSealed } = this.sys;
|
|
2380
2381
|
if (path !== SEALED_PATH || !openSealed) return void 0;
|
|
2381
|
-
const kfd = this.call(() => openSealed.call(this.sys));
|
|
2382
|
+
const kfd = this.call(() => openSealed.call(this.sys, flags & 3));
|
|
2382
2383
|
return this.vessel(open, kfd, { path, flags, mode }, false);
|
|
2383
2384
|
}
|
|
2384
2385
|
openClipboard(open, path, flags, mode) {
|
|
@@ -3433,8 +3434,8 @@ function describeInherited(Fs, sys, streams, livePath, actions = []) {
|
|
|
3433
3434
|
const out = [];
|
|
3434
3435
|
for (const [fd, stream] of slots3) {
|
|
3435
3436
|
promote(stream);
|
|
3436
|
-
const
|
|
3437
|
-
if (
|
|
3437
|
+
const slot2 = inheritedSlot(fd, stream);
|
|
3438
|
+
if (slot2) out.push(slot2);
|
|
3438
3439
|
}
|
|
3439
3440
|
return out;
|
|
3440
3441
|
}
|
|
@@ -3652,7 +3653,7 @@ function createProcessKernel(deps) {
|
|
|
3652
3653
|
const reaped = /* @__PURE__ */ new Map();
|
|
3653
3654
|
const call2 = (req, label) => transport.call(req, Infinity, label);
|
|
3654
3655
|
const at = (path) => path === "" || path.startsWith("/") ? path : `${Fs.cwd()}/${path}`;
|
|
3655
|
-
const
|
|
3656
|
+
const slot2 = (fd, n, promote) => {
|
|
3656
3657
|
const stream = fd >= 0 ? Fs.getStream(fd) : null;
|
|
3657
3658
|
if (!stream) return { none: true };
|
|
3658
3659
|
promote?.(stream);
|
|
@@ -3701,7 +3702,7 @@ function createProcessKernel(deps) {
|
|
|
3701
3702
|
const unflushed = flushed(deps.beforeSpawn);
|
|
3702
3703
|
if (unflushed < 0) return unflushed;
|
|
3703
3704
|
const promote = deps.stdioPromoter?.();
|
|
3704
|
-
const stdio = [0, 1, 2].map((n) =>
|
|
3705
|
+
const stdio = [0, 1, 2].map((n) => slot2(fds[n] ?? -1, n, promote));
|
|
3705
3706
|
const inherit = deps.inherit?.(actions) ?? [];
|
|
3706
3707
|
const req = {
|
|
3707
3708
|
op: "proc-spawn",
|
|
@@ -3940,7 +3941,7 @@ var init_process_signals = __esm({
|
|
|
3940
3941
|
interrupt() {
|
|
3941
3942
|
this.report();
|
|
3942
3943
|
const header = this.header;
|
|
3943
|
-
const pending = Atomics.load(header, SAB_I_SIGNALS) | Atomics.load(header, SAB_I_TIMERS) | Atomics.load(header, SAB_I_KILLED);
|
|
3944
|
+
const pending = Atomics.load(header, SAB_I_SIGNALS) & ~Atomics.load(header, SAB_I_BLOCKED) | Atomics.load(header, SAB_I_TIMERS) | Atomics.load(header, SAB_I_KILLED);
|
|
3944
3945
|
if (pending === 0) return false;
|
|
3945
3946
|
this.deliver();
|
|
3946
3947
|
return true;
|
|
@@ -3953,7 +3954,8 @@ var init_process_signals = __esm({
|
|
|
3953
3954
|
this.hooks.killed(killed);
|
|
3954
3955
|
}
|
|
3955
3956
|
const timers = Atomics.exchange(this.header, SAB_I_TIMERS, 0);
|
|
3956
|
-
const
|
|
3957
|
+
const blocked = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
3958
|
+
const pending = blocked === 0 ? Atomics.exchange(this.header, SAB_I_SIGNALS, 0) : Atomics.and(this.header, SAB_I_SIGNALS, blocked) & ~blocked;
|
|
3957
3959
|
if (this.depth <= 1) this.lastDelivered = pending | (timers & 1 ? sigbit(SIG.ALRM) : 0);
|
|
3958
3960
|
if (pending !== 0 || timers !== 0) this.delivered++;
|
|
3959
3961
|
for (let which = 0; which < 3; which++) {
|
|
@@ -4149,7 +4151,29 @@ var init_cred = __esm({
|
|
|
4149
4151
|
}
|
|
4150
4152
|
});
|
|
4151
4153
|
|
|
4154
|
+
// src/version.ts
|
|
4155
|
+
function procVersion() {
|
|
4156
|
+
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
4157
|
+
`;
|
|
4158
|
+
}
|
|
4159
|
+
var KERNEL_VERSION, OS_RELEASE;
|
|
4160
|
+
var init_version = __esm({
|
|
4161
|
+
"src/version.ts"() {
|
|
4162
|
+
"use strict";
|
|
4163
|
+
KERNEL_VERSION = true ? "1.88.0" : "0.0.0-dev";
|
|
4164
|
+
OS_RELEASE = "6.0.0-slicc";
|
|
4165
|
+
}
|
|
4166
|
+
});
|
|
4167
|
+
|
|
4152
4168
|
// src/process/procfs.ts
|
|
4169
|
+
function sysEntry(parts) {
|
|
4170
|
+
let at = SYS_TREE;
|
|
4171
|
+
for (const part of parts) {
|
|
4172
|
+
if (typeof at !== "object" || !Object.hasOwn(at, part)) return void 0;
|
|
4173
|
+
at = at[part];
|
|
4174
|
+
}
|
|
4175
|
+
return at;
|
|
4176
|
+
}
|
|
4153
4177
|
function commOf(info) {
|
|
4154
4178
|
const name2 = info.argv[0] ?? "";
|
|
4155
4179
|
return name2.slice(name2.lastIndexOf("/") + 1).slice(0, 15);
|
|
@@ -4234,7 +4258,7 @@ function pidStatus(info) {
|
|
|
4234
4258
|
"SigQ: 0/0",
|
|
4235
4259
|
"SigPnd: 0000000000000000",
|
|
4236
4260
|
"ShdPnd: 0000000000000000",
|
|
4237
|
-
|
|
4261
|
+
`SigBlk: ${sigMask(info.sigBlk)}`,
|
|
4238
4262
|
`SigIgn: ${sigMask(info.sigIgn)}`,
|
|
4239
4263
|
`SigCgt: ${sigMask(info.sigCgt)}`,
|
|
4240
4264
|
""
|
|
@@ -4270,6 +4294,7 @@ function memoryInfo(source, used = 0) {
|
|
|
4270
4294
|
].map(([key, value2]) => `${`${key}:`.padEnd(16)}${value2.padStart(12)}`).concat("").join("\n");
|
|
4271
4295
|
}
|
|
4272
4296
|
function systemFile(name2, listing, now, memory) {
|
|
4297
|
+
if (name2 === "version") return procVersion();
|
|
4273
4298
|
const up = Math.max(0, now - listing.boot) / 1e3;
|
|
4274
4299
|
if (name2 === "uptime") return `${up.toFixed(2)} ${up.toFixed(2)}
|
|
4275
4300
|
`;
|
|
@@ -4386,6 +4411,16 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
4386
4411
|
if (!info) throw error();
|
|
4387
4412
|
return pidFile(name2, info, listing.boot);
|
|
4388
4413
|
};
|
|
4414
|
+
const sysDir = (parent, name2, tree) => {
|
|
4415
|
+
const dir = fresh(parent, name2, DIR_MODE2);
|
|
4416
|
+
dir.node_ops.lookup = (at, child) => {
|
|
4417
|
+
if (!Object.hasOwn(tree, child)) throw error();
|
|
4418
|
+
const next2 = tree[child];
|
|
4419
|
+
return typeof next2 === "string" ? file(at, child, () => next2) : sysDir(at, child, next2);
|
|
4420
|
+
};
|
|
4421
|
+
dir.node_ops.readdir = () => [".", "..", ...Object.keys(tree)];
|
|
4422
|
+
return dir;
|
|
4423
|
+
};
|
|
4389
4424
|
const pidNames = (names) => [.../* @__PURE__ */ new Set([...names, ...PID_FILES])];
|
|
4390
4425
|
const pidDir = (name2, target) => {
|
|
4391
4426
|
const dir = fresh(proc, name2, DIR_MODE2);
|
|
@@ -4410,7 +4445,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
4410
4445
|
const readdir = procOps.readdir?.bind(procOps);
|
|
4411
4446
|
const listAll = (node) => {
|
|
4412
4447
|
const names = new Set(readdir ? readdir(node) : [".", ".."]);
|
|
4413
|
-
for (const name2 of [...SYSTEM_FILES, "mounts"]) names.add(name2);
|
|
4448
|
+
for (const name2 of [...SYSTEM_FILES, "mounts", "sys"]) names.add(name2);
|
|
4414
4449
|
for (const p of procList().processes) names.add(String(p.pid));
|
|
4415
4450
|
return [...names];
|
|
4416
4451
|
};
|
|
@@ -4422,6 +4457,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
4422
4457
|
return pidDir(name2, Number(name2));
|
|
4423
4458
|
}
|
|
4424
4459
|
if (name2 === "mounts") return file(parent, name2, () => mountTable(sys.mountList?.() ?? []));
|
|
4460
|
+
if (name2 === "sys") return sysDir(parent, name2, SYS_TREE);
|
|
4425
4461
|
if (SYSTEM_FILES.includes(name2)) {
|
|
4426
4462
|
return file(
|
|
4427
4463
|
parent,
|
|
@@ -4485,11 +4521,12 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
4485
4521
|
readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
|
|
4486
4522
|
};
|
|
4487
4523
|
}
|
|
4488
|
-
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask, STATES, tagLine;
|
|
4524
|
+
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, SYS_TREE, sigMask, STATES, tagLine;
|
|
4489
4525
|
var init_procfs = __esm({
|
|
4490
4526
|
"src/process/procfs.ts"() {
|
|
4491
4527
|
"use strict";
|
|
4492
4528
|
init_cred();
|
|
4529
|
+
init_version();
|
|
4493
4530
|
init_process_fds();
|
|
4494
4531
|
HZ = 100;
|
|
4495
4532
|
DIR_MODE2 = 16749;
|
|
@@ -4501,7 +4538,11 @@ var init_procfs = __esm({
|
|
|
4501
4538
|
KIB = 1024;
|
|
4502
4539
|
FALLBACK_MEMORY = 4 * KIB * KIB * KIB;
|
|
4503
4540
|
PID_FILES = ["cmdline", "comm", "stat", "statm", "status"];
|
|
4504
|
-
SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime"];
|
|
4541
|
+
SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime", "version"];
|
|
4542
|
+
SYS_TREE = {
|
|
4543
|
+
kernel: { osrelease: `${OS_RELEASE}
|
|
4544
|
+
`, ostype: "Linux\n" }
|
|
4545
|
+
};
|
|
4505
4546
|
sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
|
|
4506
4547
|
STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
|
|
4507
4548
|
tagLine = (tag) => `Tag: ${tag.replaceAll("\n", "\\n").replaceAll(" ", "\\t").replaceAll("\r", "\\r")}`;
|
|
@@ -4645,8 +4686,8 @@ function kernelSys(transport) {
|
|
|
4645
4686
|
openPts(n, noctty) {
|
|
4646
4687
|
return json2(call2({ op: "pty-slave-open", n, noctty }, `pty-slave-open ${n}`));
|
|
4647
4688
|
},
|
|
4648
|
-
openSealed() {
|
|
4649
|
-
return json2(call2({ op: "fd-open-sealed" }, "fd-open-sealed"));
|
|
4689
|
+
openSealed(flags) {
|
|
4690
|
+
return json2(call2({ op: "fd-open-sealed", flags }, "fd-open-sealed"));
|
|
4650
4691
|
},
|
|
4651
4692
|
openClipboard(flags) {
|
|
4652
4693
|
return json2(call2({ op: "fd-open-clipboard", flags }, "fd-open-clipboard"));
|
|
@@ -5580,9 +5621,9 @@ var init_wasi_files = __esm({
|
|
|
5580
5621
|
readable;
|
|
5581
5622
|
writable;
|
|
5582
5623
|
append;
|
|
5583
|
-
constructor(buffer,
|
|
5624
|
+
constructor(buffer, readable3, writable2, append) {
|
|
5584
5625
|
this.buffer = buffer;
|
|
5585
|
-
this.readable =
|
|
5626
|
+
this.readable = readable3;
|
|
5586
5627
|
this.writable = writable2;
|
|
5587
5628
|
this.append = append;
|
|
5588
5629
|
}
|
|
@@ -6333,12 +6374,10 @@ var init_wasi_fds = __esm({
|
|
|
6333
6374
|
let fd;
|
|
6334
6375
|
let kind;
|
|
6335
6376
|
if (path === SEALED_PATH2 && openSealed) {
|
|
6336
|
-
|
|
6337
|
-
if (oflags & OFLAGS.CREAT && oflags & OFLAGS.EXCL) throw new WasiError("EEXIST");
|
|
6338
|
-
fd = openSealed.call(this.kernel.sys);
|
|
6377
|
+
fd = this.openCharDevice(openSealed, oflags, rights);
|
|
6339
6378
|
kind = "sealed";
|
|
6340
6379
|
} else if (path === CLIPBOARD_PATH2 && openClipboard) {
|
|
6341
|
-
fd = this.
|
|
6380
|
+
fd = this.openCharDevice(openClipboard, oflags, rights);
|
|
6342
6381
|
kind = "clipboard";
|
|
6343
6382
|
} else if (path === "/dev/tty" || /^\/dev\/tty\d+$/.test(path)) {
|
|
6344
6383
|
fd = openTty?.call(this.kernel.sys, path === "/dev/tty" ? void 0 : path);
|
|
@@ -6349,12 +6388,12 @@ var init_wasi_fds = __esm({
|
|
|
6349
6388
|
this.bump();
|
|
6350
6389
|
return fd;
|
|
6351
6390
|
}
|
|
6352
|
-
|
|
6391
|
+
openCharDevice(openDevice2, oflags, rights) {
|
|
6353
6392
|
if (oflags & OFLAGS.DIRECTORY) throw new WasiError("ENOTDIR");
|
|
6354
6393
|
if (oflags & OFLAGS.CREAT && oflags & OFLAGS.EXCL) throw new WasiError("EEXIST");
|
|
6355
6394
|
const want = wantOf2(oflags, rights);
|
|
6356
6395
|
const flags = want === 6 ? O_RDWR4 : want === 2 ? O_WRONLY4 : 0;
|
|
6357
|
-
return
|
|
6396
|
+
return openDevice2.call(this.kernel.sys, flags);
|
|
6358
6397
|
}
|
|
6359
6398
|
open(path, oflags, rights, fdflags) {
|
|
6360
6399
|
const device2 = deviceOf(path);
|
|
@@ -6406,7 +6445,7 @@ var init_wasi_fds = __esm({
|
|
|
6406
6445
|
}
|
|
6407
6446
|
}
|
|
6408
6447
|
file(path, existing, oflags, rights, fdflags) {
|
|
6409
|
-
const { readable:
|
|
6448
|
+
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
6410
6449
|
let buffer = this.buffers.get(path);
|
|
6411
6450
|
if (buffer?.handle !== void 0 && this.fs.kept?.(buffer.handle)) {
|
|
6412
6451
|
this.buffers.delete(path);
|
|
@@ -6421,7 +6460,7 @@ var init_wasi_fds = __esm({
|
|
|
6421
6460
|
buffer = this.freshBuffer(path, existing, oflags, want);
|
|
6422
6461
|
}
|
|
6423
6462
|
buffer.opens++;
|
|
6424
|
-
return new LocalFile(buffer,
|
|
6463
|
+
return new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
|
|
6425
6464
|
}
|
|
6426
6465
|
freshBuffer(path, existing, oflags, want) {
|
|
6427
6466
|
const made = !existing && this.createNew(path, oflags);
|
|
@@ -6440,9 +6479,9 @@ var init_wasi_fds = __esm({
|
|
|
6440
6479
|
return buffer;
|
|
6441
6480
|
}
|
|
6442
6481
|
kernelFile(path, existing, oflags, rights, fdflags) {
|
|
6443
|
-
const { readable:
|
|
6482
|
+
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
6444
6483
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
6445
|
-
const flags = (writable2 ?
|
|
6484
|
+
const flags = (writable2 ? readable3 ? O_RDWR4 : O_WRONLY4 : 0) | (append ? O_APPEND : 0);
|
|
6446
6485
|
const made = !existing && this.createNew(path, oflags);
|
|
6447
6486
|
const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
6448
6487
|
const fd = this.kernel.sys.openVfs(path, flags, 0, {
|
|
@@ -6843,7 +6882,7 @@ function wrap(table) {
|
|
|
6843
6882
|
}
|
|
6844
6883
|
return out;
|
|
6845
6884
|
}
|
|
6846
|
-
var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SEALED_MODE, WasiHost;
|
|
6885
|
+
var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
6847
6886
|
var init_wasi_host = __esm({
|
|
6848
6887
|
"src/process/wasi/wasi-host.ts"() {
|
|
6849
6888
|
"use strict";
|
|
@@ -6874,6 +6913,7 @@ var init_wasi_host = __esm({
|
|
|
6874
6913
|
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS;
|
|
6875
6914
|
MAX_READ = 1024 * 1024;
|
|
6876
6915
|
SIGPIPE_EXIT = 141;
|
|
6916
|
+
SIG_IGN = 1;
|
|
6877
6917
|
SEALED_MODE = 8630;
|
|
6878
6918
|
WasiHost = class {
|
|
6879
6919
|
mem = new WasiMemory();
|
|
@@ -6885,6 +6925,7 @@ var init_wasi_host = __esm({
|
|
|
6885
6925
|
onRaise;
|
|
6886
6926
|
muted;
|
|
6887
6927
|
signals;
|
|
6928
|
+
sigmask;
|
|
6888
6929
|
interrupted;
|
|
6889
6930
|
quietly = (fn) => fn();
|
|
6890
6931
|
listening;
|
|
@@ -7076,7 +7117,23 @@ var init_wasi_host = __esm({
|
|
|
7076
7117
|
const groups = Array.from({ length: n }, (_, i) => view.getUint32(buf + i * 4, true));
|
|
7077
7118
|
void this.o.kernel.call({ op: "proc-setcred", change: { groups } });
|
|
7078
7119
|
},
|
|
7079
|
-
sigaction_set: (sig, disposition, flags) =>
|
|
7120
|
+
sigaction_set: (sig, disposition, flags) => {
|
|
7121
|
+
if (!this.signals) return E.NOSYS;
|
|
7122
|
+
const errno2 = this.signals.disposition(sig, disposition, flags);
|
|
7123
|
+
if (errno2 === E.SUCCESS && disposition === SIG_IGN) this.sigmask?.discard(sig);
|
|
7124
|
+
return errno2;
|
|
7125
|
+
},
|
|
7126
|
+
sigmask_set: (how, lo, hi, old) => this.sigmask ? this.sigmask.set(how, lo, hi, (oldLo, oldHi) => {
|
|
7127
|
+
if (old === 0) return;
|
|
7128
|
+
const view = mem.view();
|
|
7129
|
+
view.setUint32(old, oldLo, true);
|
|
7130
|
+
view.setUint32(old + 4, oldHi, true);
|
|
7131
|
+
}) : E.NOSYS,
|
|
7132
|
+
sigpending_get: (out) => {
|
|
7133
|
+
if (!this.sigmask) return E.NOSYS;
|
|
7134
|
+
mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
|
|
7135
|
+
return E.SUCCESS;
|
|
7136
|
+
}
|
|
7080
7137
|
});
|
|
7081
7138
|
}
|
|
7082
7139
|
imports() {
|
|
@@ -7626,6 +7683,7 @@ var init_wasi_threads = __esm({
|
|
|
7626
7683
|
beforeSpawn;
|
|
7627
7684
|
modules;
|
|
7628
7685
|
received;
|
|
7686
|
+
blocked;
|
|
7629
7687
|
port;
|
|
7630
7688
|
memory;
|
|
7631
7689
|
cap;
|
|
@@ -7646,6 +7704,7 @@ var init_wasi_threads = __esm({
|
|
|
7646
7704
|
this.beforeSpawn?.();
|
|
7647
7705
|
const tid = Atomics.add(this.ids, LAST_TID, 1) + 1;
|
|
7648
7706
|
const modules = this.modules?.();
|
|
7707
|
+
const blocked = this.blocked?.() ?? 0;
|
|
7649
7708
|
this.port.postMessage({
|
|
7650
7709
|
type: WASM_THREAD_SPAWN,
|
|
7651
7710
|
thread: {
|
|
@@ -7653,7 +7712,8 @@ var init_wasi_threads = __esm({
|
|
|
7653
7712
|
arg,
|
|
7654
7713
|
memory: this.memory,
|
|
7655
7714
|
ids: this.ids.buffer,
|
|
7656
|
-
...modules ? { modules } : {}
|
|
7715
|
+
...modules ? { modules } : {},
|
|
7716
|
+
...blocked ? { blocked } : {}
|
|
7657
7717
|
}
|
|
7658
7718
|
});
|
|
7659
7719
|
return tid;
|
|
@@ -8041,7 +8101,7 @@ function importsContext({
|
|
|
8041
8101
|
}
|
|
8042
8102
|
function processes(host, call2, inThread) {
|
|
8043
8103
|
const close = (fd) => void call2({ op: "fd-close", fd });
|
|
8044
|
-
const
|
|
8104
|
+
const slot2 = (n, how, mine, theirs) => {
|
|
8045
8105
|
if (how === "inherit") return { fd: n };
|
|
8046
8106
|
if (how === "null") return { none: true };
|
|
8047
8107
|
const [read2, write2] = call2({ op: "fd-pipe" });
|
|
@@ -8055,7 +8115,7 @@ function processes(host, call2, inThread) {
|
|
|
8055
8115
|
const theirs = [];
|
|
8056
8116
|
host.fds.promoteFiles();
|
|
8057
8117
|
try {
|
|
8058
|
-
const stdio = STDIO.map((name2, n) =>
|
|
8118
|
+
const stdio = STDIO.map((name2, n) => slot2(n, o[name2] ?? "inherit", mine, theirs));
|
|
8059
8119
|
const req = {
|
|
8060
8120
|
op: "proc-spawn",
|
|
8061
8121
|
file: o.argv[0],
|
|
@@ -8394,11 +8454,17 @@ var init_wasi_procfs = __esm({
|
|
|
8394
8454
|
names: () => [
|
|
8395
8455
|
...SYSTEM_NAMES,
|
|
8396
8456
|
"mounts",
|
|
8457
|
+
"sys",
|
|
8397
8458
|
"self",
|
|
8398
8459
|
...this.listing().processes.map((p) => String(p.pid))
|
|
8399
8460
|
]
|
|
8400
8461
|
};
|
|
8401
8462
|
}
|
|
8463
|
+
if (top === "sys") {
|
|
8464
|
+
const entry = sysEntry(parts.slice(1));
|
|
8465
|
+
if (typeof entry === "string") return { kind: "file", content: () => entry };
|
|
8466
|
+
return entry && { kind: "dir", names: () => Object.keys(entry) };
|
|
8467
|
+
}
|
|
8402
8468
|
if (top === "self") {
|
|
8403
8469
|
return leaf === void 0 ? { kind: "link", target: String(this.pid) } : void 0;
|
|
8404
8470
|
}
|
|
@@ -8482,6 +8548,63 @@ var init_wasi_procfs = __esm({
|
|
|
8482
8548
|
}
|
|
8483
8549
|
});
|
|
8484
8550
|
|
|
8551
|
+
// src/process/wasi/wasi-sigmask.ts
|
|
8552
|
+
var UNBLOCKABLE, LIBC_UNBLOCKABLE, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
8553
|
+
var init_wasi_sigmask = __esm({
|
|
8554
|
+
"src/process/wasi/wasi-sigmask.ts"() {
|
|
8555
|
+
"use strict";
|
|
8556
|
+
init_signals();
|
|
8557
|
+
init_sync_sab_wire();
|
|
8558
|
+
init_wasi_abi();
|
|
8559
|
+
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
8560
|
+
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
8561
|
+
SIG_BLOCK = 0;
|
|
8562
|
+
SIG_UNBLOCK = 1;
|
|
8563
|
+
SIG_SETMASK = 2;
|
|
8564
|
+
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
8565
|
+
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
8566
|
+
apply = (how, mask, set) => {
|
|
8567
|
+
if (how === SIG_BLOCK) return mask | set;
|
|
8568
|
+
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
8569
|
+
return set;
|
|
8570
|
+
};
|
|
8571
|
+
WasiSigmask = class {
|
|
8572
|
+
lo;
|
|
8573
|
+
hi = 0;
|
|
8574
|
+
header;
|
|
8575
|
+
deliver;
|
|
8576
|
+
process;
|
|
8577
|
+
constructor(header, deliver, process) {
|
|
8578
|
+
this.header = header;
|
|
8579
|
+
this.deliver = deliver;
|
|
8580
|
+
this.process = process;
|
|
8581
|
+
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
8582
|
+
}
|
|
8583
|
+
static unsupported(header) {
|
|
8584
|
+
Atomics.store(header, SAB_I_BLOCKED, 0);
|
|
8585
|
+
}
|
|
8586
|
+
set(how, setLo, setHi, old) {
|
|
8587
|
+
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
8588
|
+
old(this.lo >>> 0, this.hi >>> 0);
|
|
8589
|
+
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
8590
|
+
this.hi = apply(how, this.hi, setHi | 0);
|
|
8591
|
+
const now = kernelBits(this.lo);
|
|
8592
|
+
Atomics.store(this.header, SAB_I_BLOCKED, now);
|
|
8593
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
8594
|
+
return E.SUCCESS;
|
|
8595
|
+
}
|
|
8596
|
+
discard(sig) {
|
|
8597
|
+
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
8598
|
+
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
8599
|
+
}
|
|
8600
|
+
pending() {
|
|
8601
|
+
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
8602
|
+
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
8603
|
+
}
|
|
8604
|
+
};
|
|
8605
|
+
}
|
|
8606
|
+
});
|
|
8607
|
+
|
|
8485
8608
|
// src/process/wasi/wasi-signals.ts
|
|
8486
8609
|
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
8487
8610
|
var init_wasi_signals = __esm({
|
|
@@ -8567,7 +8690,11 @@ var init_wasi_signals = __esm({
|
|
|
8567
8690
|
}
|
|
8568
8691
|
raise(sig) {
|
|
8569
8692
|
const handler = this.handler();
|
|
8570
|
-
if (!handler) return;
|
|
8693
|
+
if (!handler && !this.hooked) return;
|
|
8694
|
+
if (!handler || this.hooked && (this.handlers & sigbit(sig)) === 0) {
|
|
8695
|
+
if ((this.ignoring & sigbit(sig)) === 0) this.defaultAction(sig);
|
|
8696
|
+
return;
|
|
8697
|
+
}
|
|
8571
8698
|
const outer = { sig: this.delivering, defaulted: this.defaulted, libc: this.libcDefault };
|
|
8572
8699
|
this.delivering = sig;
|
|
8573
8700
|
this.defaulted = false;
|
|
@@ -10444,6 +10571,7 @@ __export(wasi_runtime_exports, {
|
|
|
10444
10571
|
delivering: () => delivering,
|
|
10445
10572
|
runWasiProcess: () => runWasiProcess,
|
|
10446
10573
|
runWasiThread: () => runWasiThread,
|
|
10574
|
+
sigmaskOf: () => sigmaskOf,
|
|
10447
10575
|
trapMessage: () => trapMessage,
|
|
10448
10576
|
unsupportedImport: () => unsupportedImport,
|
|
10449
10577
|
wireSignals: () => wireSignals
|
|
@@ -10480,6 +10608,16 @@ function delivering(ns, table, host, driver, before) {
|
|
|
10480
10608
|
}
|
|
10481
10609
|
return out;
|
|
10482
10610
|
}
|
|
10611
|
+
function sigmaskOf(module, sab, gate, threads, process) {
|
|
10612
|
+
const header = new Int32Array(sab, 0, SAB_HEADER_I32);
|
|
10613
|
+
if (!importsSlicc(module, "sigmask_set")) {
|
|
10614
|
+
WasiSigmask.unsupported(header);
|
|
10615
|
+
return void 0;
|
|
10616
|
+
}
|
|
10617
|
+
if (threads) threads.blocked = () => Atomics.load(header, SAB_I_BLOCKED);
|
|
10618
|
+
const shared = process && new Int32Array(process, 0, SAB_HEADER_I32);
|
|
10619
|
+
return new WasiSigmask(header, () => gate.deliver(), shared);
|
|
10620
|
+
}
|
|
10483
10621
|
function enosys(module, name2, foreign) {
|
|
10484
10622
|
const type = foreign?.[module]?.[name2];
|
|
10485
10623
|
if (type === "other") throw new Error(noErrno(`${module}.${name2}`));
|
|
@@ -10793,6 +10931,7 @@ async function runWasiProcess(init, port2) {
|
|
|
10793
10931
|
),
|
|
10794
10932
|
...descriptors(init, fork, threads)
|
|
10795
10933
|
});
|
|
10934
|
+
host.sigmask = sigmaskOf(module, init.sab, gate, threads);
|
|
10796
10935
|
if (threads) {
|
|
10797
10936
|
threads.beforeSpawn = () => {
|
|
10798
10937
|
if (!host.fds.isShared) host.fds.share(threads.ids, false);
|
|
@@ -10887,6 +11026,7 @@ async function runWasiThread(init, port2) {
|
|
|
10887
11026
|
),
|
|
10888
11027
|
shared: threads.ids
|
|
10889
11028
|
});
|
|
11029
|
+
host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
|
|
10890
11030
|
const program = await programImports(init.program, host, transport, thread.tid);
|
|
10891
11031
|
const { instance } = await instantiate(host, init.program.module, thread.memory, threads, {
|
|
10892
11032
|
thread: true,
|
|
@@ -10922,7 +11062,7 @@ async function runWasiThread(init, port2) {
|
|
|
10922
11062
|
throw e;
|
|
10923
11063
|
}
|
|
10924
11064
|
}
|
|
10925
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, UNDELIVERED, DELIVERED, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
11065
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, UNDELIVERED, DELIVERED, importsSlicc, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
10926
11066
|
var init_wasi_runtime = __esm({
|
|
10927
11067
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
10928
11068
|
"use strict";
|
|
@@ -10940,6 +11080,7 @@ var init_wasi_runtime = __esm({
|
|
|
10940
11080
|
init_wasi_imports();
|
|
10941
11081
|
init_wasi_module();
|
|
10942
11082
|
init_wasi_procfs();
|
|
11083
|
+
init_wasi_sigmask();
|
|
10943
11084
|
init_wasi_signals();
|
|
10944
11085
|
init_wasi_stats();
|
|
10945
11086
|
init_wasi_threads();
|
|
@@ -10966,7 +11107,8 @@ var init_wasi_runtime = __esm({
|
|
|
10966
11107
|
wasi: ["thread-spawn"]
|
|
10967
11108
|
};
|
|
10968
11109
|
DELIVERED = [PREVIEW1, WASIX, SLICC, SLICC_FS, SLICC_TTY];
|
|
10969
|
-
|
|
11110
|
+
importsSlicc = (module, name2) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === name2);
|
|
11111
|
+
importsSigactionHook = (module) => importsSlicc(module, "sigaction_set");
|
|
10970
11112
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
10971
11113
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
10972
11114
|
LinkSync = class {
|
|
@@ -11383,7 +11525,7 @@ function writable(io, fd) {
|
|
|
11383
11525
|
abort: () => io.close(fd)
|
|
11384
11526
|
});
|
|
11385
11527
|
}
|
|
11386
|
-
function childOps(kernel, io, defaults) {
|
|
11528
|
+
function childOps(kernel, io, defaults, sync) {
|
|
11387
11529
|
const wait2 = async (pid) => {
|
|
11388
11530
|
const r = await kernel.blocking({ op: "proc-wait", pid, nohang: false });
|
|
11389
11531
|
const [, status2] = r.ok && r.kind === "json" ? r.json : [0, 0];
|
|
@@ -11403,25 +11545,45 @@ function childOps(kernel, io, defaults) {
|
|
|
11403
11545
|
kill: (signal) => kill(pid, signal)
|
|
11404
11546
|
};
|
|
11405
11547
|
};
|
|
11406
|
-
const
|
|
11548
|
+
const request = (o) => {
|
|
11407
11549
|
const [file] = o.argv;
|
|
11408
11550
|
if (file === void 0) throw new JsCallError("EINVAL", "spawn");
|
|
11409
11551
|
const group = groupOf(o, "spawn");
|
|
11410
11552
|
const named = argv0Of(o.argv0, "spawn");
|
|
11553
|
+
const death = deathOf(o.parentDeathSignal, defaults);
|
|
11554
|
+
return (stdio) => ({
|
|
11555
|
+
op: "proc-spawn",
|
|
11556
|
+
file,
|
|
11557
|
+
argv: [...o.argv],
|
|
11558
|
+
...named,
|
|
11559
|
+
env: { ...o.env ?? defaults.env },
|
|
11560
|
+
cwd: o.cwd ?? defaults.cwd,
|
|
11561
|
+
stdio,
|
|
11562
|
+
...group,
|
|
11563
|
+
...death
|
|
11564
|
+
});
|
|
11565
|
+
};
|
|
11566
|
+
const spawnSync = (o) => {
|
|
11567
|
+
const spawning = request(o);
|
|
11568
|
+
const mine = [];
|
|
11569
|
+
const theirs = [];
|
|
11570
|
+
try {
|
|
11571
|
+
const stdio = slotsSync(sync, o, mine, theirs);
|
|
11572
|
+
return childOf(sync.json(spawning(stdio)), mine);
|
|
11573
|
+
} catch (err) {
|
|
11574
|
+
closeAllSync(sync, mine);
|
|
11575
|
+
throw err;
|
|
11576
|
+
} finally {
|
|
11577
|
+
closeAllSync(sync, theirs);
|
|
11578
|
+
}
|
|
11579
|
+
};
|
|
11580
|
+
const spawn = async (o) => {
|
|
11581
|
+
const spawning = request(o);
|
|
11411
11582
|
const mine = [];
|
|
11412
11583
|
const theirs = [];
|
|
11413
11584
|
try {
|
|
11414
11585
|
const stdio = await slots2(kernel, o, mine, theirs);
|
|
11415
|
-
const pid = await kernel.json(
|
|
11416
|
-
op: "proc-spawn",
|
|
11417
|
-
file,
|
|
11418
|
-
argv: [...o.argv],
|
|
11419
|
-
...named,
|
|
11420
|
-
env: { ...o.env ?? defaults.env },
|
|
11421
|
-
cwd: o.cwd ?? defaults.cwd,
|
|
11422
|
-
stdio,
|
|
11423
|
-
...group
|
|
11424
|
-
});
|
|
11586
|
+
const pid = await kernel.json(spawning(stdio));
|
|
11425
11587
|
return childOf(pid, mine);
|
|
11426
11588
|
} catch (err) {
|
|
11427
11589
|
await closeAll(io, mine);
|
|
@@ -11430,7 +11592,7 @@ function childOps(kernel, io, defaults) {
|
|
|
11430
11592
|
await closeAll(io, theirs);
|
|
11431
11593
|
}
|
|
11432
11594
|
};
|
|
11433
|
-
return { spawn, wait: wait2, kill };
|
|
11595
|
+
return { spawn, wait: wait2, kill, spawnSync };
|
|
11434
11596
|
}
|
|
11435
11597
|
function groupOf(o, call2) {
|
|
11436
11598
|
const { pgid, session } = o;
|
|
@@ -11441,6 +11603,13 @@ function groupOf(o, call2) {
|
|
|
11441
11603
|
if (session && pgid !== void 0) throw new JsCallError("EINVAL", call2);
|
|
11442
11604
|
return session ? { session: true } : pgid !== void 0 ? { pgid } : {};
|
|
11443
11605
|
}
|
|
11606
|
+
function deathOf(signal, defaults) {
|
|
11607
|
+
if (signal === void 0) return {};
|
|
11608
|
+
if (typeof signal !== "number" && typeof signal !== "string") {
|
|
11609
|
+
throw new JsCallError("EINVAL", "spawn");
|
|
11610
|
+
}
|
|
11611
|
+
return { deathSignal: defaults.signal(signal) };
|
|
11612
|
+
}
|
|
11444
11613
|
function argv0Of(argv0, call2) {
|
|
11445
11614
|
if (argv0 === void 0) return {};
|
|
11446
11615
|
if (typeof argv0 !== "string") throw new JsCallError("EINVAL", call2);
|
|
@@ -11449,27 +11618,43 @@ function argv0Of(argv0, call2) {
|
|
|
11449
11618
|
async function closeAll(io, fds) {
|
|
11450
11619
|
for (const fd of fds) if (fd !== void 0) await io.close(fd).catch(() => void 0);
|
|
11451
11620
|
}
|
|
11452
|
-
|
|
11621
|
+
function closeAllSync(sync, fds) {
|
|
11622
|
+
for (const fd of fds) if (fd !== void 0) sync.raw({ op: "fd-close", fd });
|
|
11623
|
+
}
|
|
11624
|
+
function checked(hows) {
|
|
11625
|
+
const fds = [];
|
|
11453
11626
|
for (const [n, how] of hows.entries()) {
|
|
11454
11627
|
if (how === "pipe" || how === "null") continue;
|
|
11455
11628
|
if (how !== "inherit" && typeof how !== "number") throw new JsCallError("EINVAL", "spawn");
|
|
11456
|
-
|
|
11629
|
+
fds.push(how === "inherit" ? n : how);
|
|
11457
11630
|
}
|
|
11631
|
+
return fds;
|
|
11632
|
+
}
|
|
11633
|
+
async function preflight(kernel, hows) {
|
|
11634
|
+
for (const fd of checked(hows)) await kernel.json({ op: "fd-info", fd });
|
|
11635
|
+
}
|
|
11636
|
+
function slot(n, how, pipe, mine, theirs) {
|
|
11637
|
+
if (how === "inherit") return { fd: n };
|
|
11638
|
+
if (how === "null") return { none: true };
|
|
11639
|
+
if (typeof how === "number") return { fd: how };
|
|
11640
|
+
const [read2, write2] = pipe();
|
|
11641
|
+
mine[n] = n === 0 ? write2 : read2;
|
|
11642
|
+
theirs.push(n === 0 ? read2 : write2);
|
|
11643
|
+
return { fd: n === 0 ? read2 : write2 };
|
|
11644
|
+
}
|
|
11645
|
+
function slotsSync(sync, o, mine, theirs) {
|
|
11646
|
+
const hows = STDIO2.map((name2) => o[name2] ?? "inherit");
|
|
11647
|
+
for (const fd of checked(hows)) sync.json({ op: "fd-info", fd });
|
|
11648
|
+
const pipe = () => sync.json({ op: "fd-pipe" });
|
|
11649
|
+
return hows.map((how, n) => slot(n, how, pipe, mine, theirs));
|
|
11458
11650
|
}
|
|
11459
11651
|
async function slots2(kernel, o, mine, theirs) {
|
|
11460
11652
|
const hows = STDIO2.map((name2) => o[name2] ?? "inherit");
|
|
11461
11653
|
await preflight(kernel, hows);
|
|
11462
11654
|
const stdio = [];
|
|
11463
11655
|
for (const [n, how] of hows.entries()) {
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
else if (typeof how === "number") stdio.push({ fd: how });
|
|
11467
|
-
else {
|
|
11468
|
-
const [read2, write2] = await kernel.json({ op: "fd-pipe" });
|
|
11469
|
-
mine[n] = n === 0 ? write2 : read2;
|
|
11470
|
-
theirs.push(n === 0 ? read2 : write2);
|
|
11471
|
-
stdio.push({ fd: n === 0 ? read2 : write2 });
|
|
11472
|
-
}
|
|
11656
|
+
const pair = how === "pipe" ? await kernel.json({ op: "fd-pipe" }) : [];
|
|
11657
|
+
stdio.push(slot(n, how, () => pair, mine, theirs));
|
|
11473
11658
|
}
|
|
11474
11659
|
return stdio;
|
|
11475
11660
|
}
|
|
@@ -11735,6 +11920,10 @@ function* aliasOf(fd, abs, o) {
|
|
|
11735
11920
|
}
|
|
11736
11921
|
return { fd: copy2, file };
|
|
11737
11922
|
}
|
|
11923
|
+
function accessFlags(o) {
|
|
11924
|
+
const write2 = o.write === true || o.append === true || o.truncate === true;
|
|
11925
|
+
return write2 ? o.read === true ? 2 : 1 : 0;
|
|
11926
|
+
}
|
|
11738
11927
|
function* opened(abs, o) {
|
|
11739
11928
|
const node = yield* lookup(abs);
|
|
11740
11929
|
if (isExclusive(o)) throw new JsCallError("EEXIST", abs);
|
|
@@ -11743,13 +11932,13 @@ function* opened(abs, o) {
|
|
|
11743
11932
|
return { fd: yield openRequest(abs, { ...o, create: false }), file: false };
|
|
11744
11933
|
case "tty":
|
|
11745
11934
|
return { fd: yield { op: "fd-open-tty" }, file: false };
|
|
11746
|
-
case "clipboard":
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11935
|
+
case "clipboard":
|
|
11936
|
+
return {
|
|
11937
|
+
fd: yield { op: "fd-open-clipboard", flags: accessFlags(o) },
|
|
11938
|
+
file: false
|
|
11939
|
+
};
|
|
11751
11940
|
case "sealed":
|
|
11752
|
-
return { fd: yield { op: "fd-open-sealed" }, file: false };
|
|
11941
|
+
return { fd: yield { op: "fd-open-sealed", flags: accessFlags(o) }, file: false };
|
|
11753
11942
|
case "terminal": {
|
|
11754
11943
|
const req = node.pts === void 0 ? { op: "fd-open-tty", name: node.name } : { op: "pty-slave-open", n: node.pts, noctty: true };
|
|
11755
11944
|
return { fd: yield req, file: false };
|
|
@@ -12380,7 +12569,7 @@ function netOps(kernel, io) {
|
|
|
12380
12569
|
return closed;
|
|
12381
12570
|
};
|
|
12382
12571
|
const shut = (how) => kernel.raw({ op: "sock-shutdown", fd, how });
|
|
12383
|
-
const
|
|
12572
|
+
const readable3 = new ReadableStream(
|
|
12384
12573
|
{
|
|
12385
12574
|
async pull(controller) {
|
|
12386
12575
|
const chunk = await io.read(fd, void 0, stop.signal);
|
|
@@ -12396,7 +12585,7 @@ function netOps(kernel, io) {
|
|
|
12396
12585
|
close: async () => void await shut(SHUT_WR),
|
|
12397
12586
|
abort: () => close()
|
|
12398
12587
|
});
|
|
12399
|
-
return { fd, local: local2, remote, readable:
|
|
12588
|
+
return { fd, local: local2, remote, readable: readable3, writable: writable2, close };
|
|
12400
12589
|
};
|
|
12401
12590
|
const resolve = async (host, signal) => {
|
|
12402
12591
|
if (IPV4.test(host)) return host;
|
|
@@ -13009,7 +13198,7 @@ function websocketOp(kernel) {
|
|
|
13009
13198
|
reason: closeReason(how.reason)
|
|
13010
13199
|
});
|
|
13011
13200
|
};
|
|
13012
|
-
const
|
|
13201
|
+
const readable3 = new ReadableStream(
|
|
13013
13202
|
{
|
|
13014
13203
|
async pull(controller) {
|
|
13015
13204
|
let r;
|
|
@@ -13059,7 +13248,7 @@ function websocketOp(kernel) {
|
|
|
13059
13248
|
close: () => close(),
|
|
13060
13249
|
abort: () => close({ code: 1e3, reason: "" })
|
|
13061
13250
|
});
|
|
13062
|
-
return { url, protocol, readable:
|
|
13251
|
+
return { url, protocol, readable: readable3, writable: writable2, closed, close };
|
|
13063
13252
|
};
|
|
13064
13253
|
}
|
|
13065
13254
|
var SEND_BUFFER, MAX_REASON, NEVER2, wait;
|
|
@@ -13092,9 +13281,11 @@ function signalNumber(signal) {
|
|
|
13092
13281
|
if (Number.isInteger(signal) && signal >= 1 && signal <= 31) return signal;
|
|
13093
13282
|
throw new JsCallError("EINVAL", `signal ${signal}`);
|
|
13094
13283
|
}
|
|
13095
|
-
const
|
|
13096
|
-
if (
|
|
13097
|
-
|
|
13284
|
+
const name2 = signal.slice(3);
|
|
13285
|
+
if (!signal.startsWith("SIG") || !Object.hasOwn(SIG, name2)) {
|
|
13286
|
+
throw new JsCallError("EINVAL", `signal ${signal}`);
|
|
13287
|
+
}
|
|
13288
|
+
return SIG[name2];
|
|
13098
13289
|
}
|
|
13099
13290
|
function resolvePath(cwd, path) {
|
|
13100
13291
|
const parts = [];
|
|
@@ -13164,6 +13355,18 @@ function writer(kernel, info, pid) {
|
|
|
13164
13355
|
};
|
|
13165
13356
|
return { writes, writeAll };
|
|
13166
13357
|
}
|
|
13358
|
+
function readable2(read2) {
|
|
13359
|
+
return new ReadableStream(
|
|
13360
|
+
{
|
|
13361
|
+
async pull(controller) {
|
|
13362
|
+
const chunk = await read2(0);
|
|
13363
|
+
if (chunk.length === 0) controller.close();
|
|
13364
|
+
else controller.enqueue(chunk);
|
|
13365
|
+
}
|
|
13366
|
+
},
|
|
13367
|
+
{ highWaterMark: 0 }
|
|
13368
|
+
);
|
|
13369
|
+
}
|
|
13167
13370
|
function createContext(o) {
|
|
13168
13371
|
const { kernel } = o;
|
|
13169
13372
|
const infos = /* @__PURE__ */ new Map();
|
|
@@ -13244,8 +13447,10 @@ function createContext(o) {
|
|
|
13244
13447
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
13245
13448
|
const terminal = ttyOps(kernel);
|
|
13246
13449
|
const sync = {
|
|
13450
|
+
kernel: KERNEL_INFO,
|
|
13247
13451
|
...syncOps(syncKernel, { pid: o.pid, resolve, random, infos, handles }),
|
|
13248
13452
|
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
|
|
13453
|
+
spawn: (options) => spawnSync(options),
|
|
13249
13454
|
exit: (status2 = 0) => {
|
|
13250
13455
|
exiting ??= status2 & 255;
|
|
13251
13456
|
return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
|
|
@@ -13260,9 +13465,11 @@ function createContext(o) {
|
|
|
13260
13465
|
}
|
|
13261
13466
|
};
|
|
13262
13467
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
13263
|
-
const
|
|
13468
|
+
const defaults = { env: o.env, cwd: o.cwd, signal: signalNumber };
|
|
13469
|
+
const { spawnSync, ...children } = childOps(kernel, io, defaults, syncKernel);
|
|
13264
13470
|
const strays = o.strays ?? { exception: /* @__PURE__ */ new Set(), rejection: /* @__PURE__ */ new Set() };
|
|
13265
13471
|
const ctx = {
|
|
13472
|
+
kernel: KERNEL_INFO,
|
|
13266
13473
|
argv: o.argv,
|
|
13267
13474
|
env: o.env,
|
|
13268
13475
|
pid: o.pid,
|
|
@@ -13270,16 +13477,7 @@ function createContext(o) {
|
|
|
13270
13477
|
return identityOf(await kernel.json({ op: "proc-identity" }), o).ppid;
|
|
13271
13478
|
},
|
|
13272
13479
|
cwd: o.cwd,
|
|
13273
|
-
stdin:
|
|
13274
|
-
{
|
|
13275
|
-
async pull(controller) {
|
|
13276
|
-
const chunk = await read2(0);
|
|
13277
|
-
if (chunk.length === 0) controller.close();
|
|
13278
|
-
else controller.enqueue(chunk);
|
|
13279
|
-
}
|
|
13280
|
-
},
|
|
13281
|
-
{ highWaterMark: 0 }
|
|
13282
|
-
),
|
|
13480
|
+
stdin: readable2(read2),
|
|
13283
13481
|
stdout: writable2(1),
|
|
13284
13482
|
stderr: writable2(2),
|
|
13285
13483
|
read: read2,
|
|
@@ -13488,12 +13686,13 @@ function pathOps(kernel, resolve, statOf, open) {
|
|
|
13488
13686
|
}
|
|
13489
13687
|
};
|
|
13490
13688
|
}
|
|
13491
|
-
var JsExit, encoder4;
|
|
13689
|
+
var KERNEL_INFO, JsExit, encoder4;
|
|
13492
13690
|
var init_js_context = __esm({
|
|
13493
13691
|
"src/process/js/js-context.ts"() {
|
|
13494
13692
|
"use strict";
|
|
13495
13693
|
init_signals();
|
|
13496
13694
|
init_sync_fs_wire();
|
|
13695
|
+
init_version();
|
|
13497
13696
|
init_js_children();
|
|
13498
13697
|
init_js_dev();
|
|
13499
13698
|
init_js_exit();
|
|
@@ -13505,6 +13704,7 @@ var init_js_context = __esm({
|
|
|
13505
13704
|
init_js_sync();
|
|
13506
13705
|
init_js_tty();
|
|
13507
13706
|
init_js_websocket();
|
|
13707
|
+
KERNEL_INFO = Object.freeze({ version: KERNEL_VERSION });
|
|
13508
13708
|
JsExit = class extends Error {
|
|
13509
13709
|
status;
|
|
13510
13710
|
constructor(status2) {
|