@ai-ecoverse/slicc-kernel 1.107.1 → 1.108.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 +7 -1
- package/dist/kernel-worker.js +27 -5
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +169 -149
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +27 -5
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +169 -149
- package/dist/process-worker.js.map +4 -4
- package/dist/types/kernel/children.d.ts +3 -0
- package/dist/types/kernel/process.d.ts +6 -0
- package/dist/types/process/process-signals.d.ts +8 -6
- package/dist/types/process/wasi/wasi-host.d.ts +1 -1
- package/dist/types/process/wasi/wasi-signals.d.ts +4 -7
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -2491,7 +2491,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
2491
2491
|
var init_version = __esm({
|
|
2492
2492
|
"src/version.ts"() {
|
|
2493
2493
|
"use strict";
|
|
2494
|
-
KERNEL_VERSION = true ? "1.
|
|
2494
|
+
KERNEL_VERSION = true ? "1.108.0" : "0.0.0-dev";
|
|
2495
2495
|
OS_RELEASE = "6.0.0-slicc";
|
|
2496
2496
|
}
|
|
2497
2497
|
});
|
|
@@ -4721,7 +4721,7 @@ var init_process_signals = __esm({
|
|
|
4721
4721
|
init_signals();
|
|
4722
4722
|
init_sync_sab_wire();
|
|
4723
4723
|
SignalGate = class {
|
|
4724
|
-
reported = { caught: 0, ignored: 0 };
|
|
4724
|
+
reported = { caught: 0, ignored: 0, nocldwait: false };
|
|
4725
4725
|
restart = 0;
|
|
4726
4726
|
lastDelivered = 0;
|
|
4727
4727
|
depth = 0;
|
|
@@ -4774,10 +4774,18 @@ var init_process_signals = __esm({
|
|
|
4774
4774
|
if (!masks) return;
|
|
4775
4775
|
this.restart = masks.restart;
|
|
4776
4776
|
const { caught, ignored, defaults = 0 } = masks;
|
|
4777
|
-
const
|
|
4777
|
+
const nocldwait = masks.nocldwait === true;
|
|
4778
|
+
const was = this.reported;
|
|
4779
|
+
const same = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
|
|
4778
4780
|
if (same && defaults === 0) return;
|
|
4779
|
-
this.reported = { caught, ignored };
|
|
4780
|
-
const req = {
|
|
4781
|
+
this.reported = { caught, ignored, nocldwait };
|
|
4782
|
+
const req = {
|
|
4783
|
+
op: "sig-mask",
|
|
4784
|
+
caught,
|
|
4785
|
+
ignored,
|
|
4786
|
+
...defaults ? { defaults } : {},
|
|
4787
|
+
...nocldwait ? { nocldwait } : {}
|
|
4788
|
+
};
|
|
4781
4789
|
this.raw.call(req, Number.POSITIVE_INFINITY, "sig-mask");
|
|
4782
4790
|
}
|
|
4783
4791
|
quiet(fn) {
|
|
@@ -7959,6 +7967,136 @@ var init_wasi_poll = __esm({
|
|
|
7959
7967
|
}
|
|
7960
7968
|
});
|
|
7961
7969
|
|
|
7970
|
+
// src/process/wasi/wasi-sigmask.ts
|
|
7971
|
+
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER, NS_PER_MS2, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
7972
|
+
var init_wasi_sigmask = __esm({
|
|
7973
|
+
"src/process/wasi/wasi-sigmask.ts"() {
|
|
7974
|
+
"use strict";
|
|
7975
|
+
init_signals();
|
|
7976
|
+
init_sync_sab_wire();
|
|
7977
|
+
init_wasi_abi();
|
|
7978
|
+
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
7979
|
+
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
7980
|
+
FOREVER = 0xffffffffffffffffn;
|
|
7981
|
+
NS_PER_MS2 = 1000000n;
|
|
7982
|
+
POLL_MS = 50;
|
|
7983
|
+
SIG_BLOCK = 0;
|
|
7984
|
+
SIG_UNBLOCK = 1;
|
|
7985
|
+
SIG_SETMASK = 2;
|
|
7986
|
+
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
7987
|
+
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
7988
|
+
apply = (how, mask, set) => {
|
|
7989
|
+
if (how === SIG_BLOCK) return mask | set;
|
|
7990
|
+
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
7991
|
+
return set;
|
|
7992
|
+
};
|
|
7993
|
+
WasiSigmask = class {
|
|
7994
|
+
lo;
|
|
7995
|
+
hi;
|
|
7996
|
+
header;
|
|
7997
|
+
deliver;
|
|
7998
|
+
process;
|
|
7999
|
+
tid;
|
|
8000
|
+
constructor(header, deliver, process, tid = 1) {
|
|
8001
|
+
this.header = header;
|
|
8002
|
+
this.deliver = deliver;
|
|
8003
|
+
this.process = process;
|
|
8004
|
+
this.tid = tid;
|
|
8005
|
+
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
8006
|
+
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
8007
|
+
}
|
|
8008
|
+
static unsupported(header) {
|
|
8009
|
+
storeBlocked(header, [0, 0]);
|
|
8010
|
+
}
|
|
8011
|
+
set(how, setLo, setHi, old) {
|
|
8012
|
+
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
8013
|
+
old(this.lo >>> 0, this.hi >>> 0);
|
|
8014
|
+
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
8015
|
+
this.hi = apply(how, this.hi, setHi | 0);
|
|
8016
|
+
const now = kernelBits(this.lo);
|
|
8017
|
+
storeBlocked(this.header, [now, this.hi]);
|
|
8018
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
8019
|
+
return E.SUCCESS;
|
|
8020
|
+
}
|
|
8021
|
+
swap(setLo, setHi) {
|
|
8022
|
+
const old = [this.lo, this.hi];
|
|
8023
|
+
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
8024
|
+
this.hi = setHi | 0;
|
|
8025
|
+
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
8026
|
+
return old;
|
|
8027
|
+
}
|
|
8028
|
+
deliverUnblocked() {
|
|
8029
|
+
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
8030
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
8031
|
+
this.deliver();
|
|
8032
|
+
return true;
|
|
8033
|
+
}
|
|
8034
|
+
restore([lo, hi]) {
|
|
8035
|
+
this.set(SIG_SETMASK, lo, hi, () => {
|
|
8036
|
+
});
|
|
8037
|
+
}
|
|
8038
|
+
blockedBits() {
|
|
8039
|
+
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
8040
|
+
}
|
|
8041
|
+
blocks(sig) {
|
|
8042
|
+
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
8043
|
+
}
|
|
8044
|
+
inherited() {
|
|
8045
|
+
return [kernelBits(this.lo), this.hi];
|
|
8046
|
+
}
|
|
8047
|
+
discard(sig) {
|
|
8048
|
+
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
8049
|
+
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
8050
|
+
}
|
|
8051
|
+
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
8052
|
+
const set = kernelBits(setLo | 0);
|
|
8053
|
+
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
8054
|
+
const deadline = value2 === FOREVER ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS2 - 1n) / NS_PER_MS2);
|
|
8055
|
+
publish(set);
|
|
8056
|
+
try {
|
|
8057
|
+
for (; ; ) {
|
|
8058
|
+
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
8059
|
+
const sig = this.take(set);
|
|
8060
|
+
if (sig !== 0) {
|
|
8061
|
+
took(sig);
|
|
8062
|
+
return E.SUCCESS;
|
|
8063
|
+
}
|
|
8064
|
+
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
8065
|
+
const left = deadline - performance.now();
|
|
8066
|
+
if (left <= 0) return E.AGAIN;
|
|
8067
|
+
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
8068
|
+
}
|
|
8069
|
+
} finally {
|
|
8070
|
+
publish(0);
|
|
8071
|
+
}
|
|
8072
|
+
}
|
|
8073
|
+
take(set) {
|
|
8074
|
+
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
8075
|
+
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
8076
|
+
if (ready === 0) continue;
|
|
8077
|
+
const bit = ready & -ready;
|
|
8078
|
+
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
8079
|
+
}
|
|
8080
|
+
return 0;
|
|
8081
|
+
}
|
|
8082
|
+
interrupted() {
|
|
8083
|
+
const killed = this.process ?? this.header;
|
|
8084
|
+
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
8085
|
+
this.deliver();
|
|
8086
|
+
return true;
|
|
8087
|
+
}
|
|
8088
|
+
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
8089
|
+
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
8090
|
+
return true;
|
|
8091
|
+
}
|
|
8092
|
+
pending() {
|
|
8093
|
+
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
8094
|
+
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
8095
|
+
}
|
|
8096
|
+
};
|
|
8097
|
+
}
|
|
8098
|
+
});
|
|
8099
|
+
|
|
7962
8100
|
// src/process/wasi/wasi-termios.ts
|
|
7963
8101
|
function writeTermios(mem, ptr, termios) {
|
|
7964
8102
|
mem.bytes(ptr, OSPEED + 4).fill(0);
|
|
@@ -8037,8 +8175,8 @@ var init_wasi_termios = __esm({
|
|
|
8037
8175
|
// src/process/wasi/wasix-epoll.ts
|
|
8038
8176
|
function timeoutMs(ns) {
|
|
8039
8177
|
const value2 = BigInt.asUintN(64, ns);
|
|
8040
|
-
if (value2 ===
|
|
8041
|
-
const ms = (value2 +
|
|
8178
|
+
if (value2 === FOREVER2) return -1;
|
|
8179
|
+
const ms = (value2 + NS_PER_MS3 - 1n) / NS_PER_MS3;
|
|
8042
8180
|
return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
|
|
8043
8181
|
}
|
|
8044
8182
|
function wasixEpollImports(host) {
|
|
@@ -8099,7 +8237,7 @@ function wasixEpollImports(host) {
|
|
|
8099
8237
|
}
|
|
8100
8238
|
};
|
|
8101
8239
|
}
|
|
8102
|
-
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS,
|
|
8240
|
+
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER2, MAX_TIMEOUT_MS, NS_PER_MS3, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, WASIX_OPS, DUAL_OPS;
|
|
8103
8241
|
var init_wasix_epoll = __esm({
|
|
8104
8242
|
"src/process/wasi/wasix-epoll.ts"() {
|
|
8105
8243
|
"use strict";
|
|
@@ -8109,9 +8247,9 @@ var init_wasix_epoll = __esm({
|
|
|
8109
8247
|
DATA_OFFSET = 8;
|
|
8110
8248
|
DATA_SIZE = 24;
|
|
8111
8249
|
MAX_EVENTS = 4096;
|
|
8112
|
-
|
|
8250
|
+
FOREVER2 = 0xffffffffffffffffn;
|
|
8113
8251
|
MAX_TIMEOUT_MS = 2147483647;
|
|
8114
|
-
|
|
8252
|
+
NS_PER_MS3 = 1000000n;
|
|
8115
8253
|
EVENTFD_SEMAPHORE = 1;
|
|
8116
8254
|
EVENTFD_NONBLOCK = 4;
|
|
8117
8255
|
EVENTFD_MAX = 0xfffffffffffffffen;
|
|
@@ -8506,7 +8644,7 @@ function filestatOf(path, s) {
|
|
|
8506
8644
|
size: BigInt(s.size),
|
|
8507
8645
|
ino: s.ino !== void 0 ? BigInt(s.ino) : pathInode(path),
|
|
8508
8646
|
...s.nlink !== void 0 ? { nlink: BigInt(s.nlink) } : {},
|
|
8509
|
-
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) *
|
|
8647
|
+
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS4
|
|
8510
8648
|
};
|
|
8511
8649
|
}
|
|
8512
8650
|
function kernelFiletype(kind) {
|
|
@@ -8556,7 +8694,7 @@ function wrap(table) {
|
|
|
8556
8694
|
}
|
|
8557
8695
|
return out;
|
|
8558
8696
|
}
|
|
8559
|
-
var WasiExit, IDS,
|
|
8697
|
+
var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
8560
8698
|
var init_wasi_host = __esm({
|
|
8561
8699
|
"src/process/wasi/wasi-host.ts"() {
|
|
8562
8700
|
"use strict";
|
|
@@ -8573,6 +8711,7 @@ var init_wasi_host = __esm({
|
|
|
8573
8711
|
init_wasi_files();
|
|
8574
8712
|
init_wasi_memory();
|
|
8575
8713
|
init_wasi_poll();
|
|
8714
|
+
init_wasi_sigmask();
|
|
8576
8715
|
init_wasi_termios();
|
|
8577
8716
|
init_wasix_epoll();
|
|
8578
8717
|
init_wasix_sockets();
|
|
@@ -8584,14 +8723,14 @@ var init_wasi_host = __esm({
|
|
|
8584
8723
|
}
|
|
8585
8724
|
};
|
|
8586
8725
|
IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
|
|
8587
|
-
|
|
8726
|
+
NS_PER_MS4 = 1000000n;
|
|
8588
8727
|
AT_SYMLINK_NOFOLLOW2 = 1;
|
|
8589
8728
|
AT_EACCESS2 = 2;
|
|
8590
8729
|
ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
|
|
8591
8730
|
GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
8592
8731
|
S_IFIFO = 4096;
|
|
8593
8732
|
DEFAULT_UMASK = 18;
|
|
8594
|
-
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) *
|
|
8733
|
+
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
|
|
8595
8734
|
MAX_READ = 1024 * 1024;
|
|
8596
8735
|
SIGPIPE_EXIT = 128 + SIG.PIPE;
|
|
8597
8736
|
SIG_IGN = 1;
|
|
@@ -8868,6 +9007,11 @@ var init_wasi_host = __esm({
|
|
|
8868
9007
|
this.entered
|
|
8869
9008
|
);
|
|
8870
9009
|
},
|
|
9010
|
+
sigaction_inherited: (out) => {
|
|
9011
|
+
const bits = this.o.kernel.call({ op: "sig-inherited" });
|
|
9012
|
+
mem.view().setBigUint64(out, BigInt(libcBits(bits) >>> 0), true);
|
|
9013
|
+
return E.SUCCESS;
|
|
9014
|
+
},
|
|
8871
9015
|
sigpending_get: (out) => {
|
|
8872
9016
|
if (!this.sigmask) return E.NOSYS;
|
|
8873
9017
|
mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
|
|
@@ -8947,7 +9091,7 @@ var init_wasi_host = __esm({
|
|
|
8947
9091
|
return this.cache;
|
|
8948
9092
|
}
|
|
8949
9093
|
now(id) {
|
|
8950
|
-
if (id === CLOCK.REALTIME) return BigInt(Date.now()) *
|
|
9094
|
+
if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS4;
|
|
8951
9095
|
if (id === CLOCK.MONOTONIC) {
|
|
8952
9096
|
return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
|
|
8953
9097
|
}
|
|
@@ -9488,7 +9632,7 @@ var init_wasi_host = __esm({
|
|
|
9488
9632
|
current ??= statOf(path);
|
|
9489
9633
|
return current[field2] ?? current.mtimeMs ?? now;
|
|
9490
9634
|
};
|
|
9491
|
-
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 /
|
|
9635
|
+
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS4) : kept(field2);
|
|
9492
9636
|
(follow2 ? this.o.fs.utimes : this.o.fs.lutimes).call(
|
|
9493
9637
|
this.o.fs,
|
|
9494
9638
|
path,
|
|
@@ -10488,138 +10632,8 @@ var init_wasi_procfs = __esm({
|
|
|
10488
10632
|
}
|
|
10489
10633
|
});
|
|
10490
10634
|
|
|
10491
|
-
// src/process/wasi/wasi-sigmask.ts
|
|
10492
|
-
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER2, NS_PER_MS4, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
10493
|
-
var init_wasi_sigmask = __esm({
|
|
10494
|
-
"src/process/wasi/wasi-sigmask.ts"() {
|
|
10495
|
-
"use strict";
|
|
10496
|
-
init_signals();
|
|
10497
|
-
init_sync_sab_wire();
|
|
10498
|
-
init_wasi_abi();
|
|
10499
|
-
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
10500
|
-
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
10501
|
-
FOREVER2 = 0xffffffffffffffffn;
|
|
10502
|
-
NS_PER_MS4 = 1000000n;
|
|
10503
|
-
POLL_MS = 50;
|
|
10504
|
-
SIG_BLOCK = 0;
|
|
10505
|
-
SIG_UNBLOCK = 1;
|
|
10506
|
-
SIG_SETMASK = 2;
|
|
10507
|
-
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
10508
|
-
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
10509
|
-
apply = (how, mask, set) => {
|
|
10510
|
-
if (how === SIG_BLOCK) return mask | set;
|
|
10511
|
-
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
10512
|
-
return set;
|
|
10513
|
-
};
|
|
10514
|
-
WasiSigmask = class {
|
|
10515
|
-
lo;
|
|
10516
|
-
hi;
|
|
10517
|
-
header;
|
|
10518
|
-
deliver;
|
|
10519
|
-
process;
|
|
10520
|
-
tid;
|
|
10521
|
-
constructor(header, deliver, process, tid = 1) {
|
|
10522
|
-
this.header = header;
|
|
10523
|
-
this.deliver = deliver;
|
|
10524
|
-
this.process = process;
|
|
10525
|
-
this.tid = tid;
|
|
10526
|
-
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
10527
|
-
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
10528
|
-
}
|
|
10529
|
-
static unsupported(header) {
|
|
10530
|
-
storeBlocked(header, [0, 0]);
|
|
10531
|
-
}
|
|
10532
|
-
set(how, setLo, setHi, old) {
|
|
10533
|
-
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
10534
|
-
old(this.lo >>> 0, this.hi >>> 0);
|
|
10535
|
-
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
10536
|
-
this.hi = apply(how, this.hi, setHi | 0);
|
|
10537
|
-
const now = kernelBits(this.lo);
|
|
10538
|
-
storeBlocked(this.header, [now, this.hi]);
|
|
10539
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
10540
|
-
return E.SUCCESS;
|
|
10541
|
-
}
|
|
10542
|
-
swap(setLo, setHi) {
|
|
10543
|
-
const old = [this.lo, this.hi];
|
|
10544
|
-
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
10545
|
-
this.hi = setHi | 0;
|
|
10546
|
-
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
10547
|
-
return old;
|
|
10548
|
-
}
|
|
10549
|
-
deliverUnblocked() {
|
|
10550
|
-
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
10551
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
10552
|
-
this.deliver();
|
|
10553
|
-
return true;
|
|
10554
|
-
}
|
|
10555
|
-
restore([lo, hi]) {
|
|
10556
|
-
this.set(SIG_SETMASK, lo, hi, () => {
|
|
10557
|
-
});
|
|
10558
|
-
}
|
|
10559
|
-
blockedBits() {
|
|
10560
|
-
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
10561
|
-
}
|
|
10562
|
-
blocks(sig) {
|
|
10563
|
-
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
10564
|
-
}
|
|
10565
|
-
inherited() {
|
|
10566
|
-
return [kernelBits(this.lo), this.hi];
|
|
10567
|
-
}
|
|
10568
|
-
discard(sig) {
|
|
10569
|
-
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
10570
|
-
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
10571
|
-
}
|
|
10572
|
-
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
10573
|
-
const set = kernelBits(setLo | 0);
|
|
10574
|
-
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
10575
|
-
const deadline = value2 === FOREVER2 ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS4 - 1n) / NS_PER_MS4);
|
|
10576
|
-
publish(set);
|
|
10577
|
-
try {
|
|
10578
|
-
for (; ; ) {
|
|
10579
|
-
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
10580
|
-
const sig = this.take(set);
|
|
10581
|
-
if (sig !== 0) {
|
|
10582
|
-
took(sig);
|
|
10583
|
-
return E.SUCCESS;
|
|
10584
|
-
}
|
|
10585
|
-
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
10586
|
-
const left = deadline - performance.now();
|
|
10587
|
-
if (left <= 0) return E.AGAIN;
|
|
10588
|
-
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
10589
|
-
}
|
|
10590
|
-
} finally {
|
|
10591
|
-
publish(0);
|
|
10592
|
-
}
|
|
10593
|
-
}
|
|
10594
|
-
take(set) {
|
|
10595
|
-
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
10596
|
-
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
10597
|
-
if (ready === 0) continue;
|
|
10598
|
-
const bit = ready & -ready;
|
|
10599
|
-
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
10600
|
-
}
|
|
10601
|
-
return 0;
|
|
10602
|
-
}
|
|
10603
|
-
interrupted() {
|
|
10604
|
-
const killed = this.process ?? this.header;
|
|
10605
|
-
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
10606
|
-
this.deliver();
|
|
10607
|
-
return true;
|
|
10608
|
-
}
|
|
10609
|
-
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
10610
|
-
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
10611
|
-
return true;
|
|
10612
|
-
}
|
|
10613
|
-
pending() {
|
|
10614
|
-
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
10615
|
-
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
10616
|
-
}
|
|
10617
|
-
};
|
|
10618
|
-
}
|
|
10619
|
-
});
|
|
10620
|
-
|
|
10621
10635
|
// src/process/wasi/wasi-signals.ts
|
|
10622
|
-
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
10636
|
+
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, SA_NOCLDWAIT, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
10623
10637
|
var init_wasi_signals = __esm({
|
|
10624
10638
|
"src/process/wasi/wasi-signals.ts"() {
|
|
10625
10639
|
"use strict";
|
|
@@ -10630,6 +10644,7 @@ var init_wasi_signals = __esm({
|
|
|
10630
10644
|
KERNEL_DEFAULTS = [SIG.TSTP, SIG.TTIN, SIG.TTOU, SIG.CHLD, SIG.CONT, SIG.URG, SIG.WINCH].map(sigbit).reduce((m, bit) => m | bit, 0);
|
|
10631
10645
|
LIBC_DEFAULT_EXIT = 127;
|
|
10632
10646
|
SA_RESTART = 268435456;
|
|
10647
|
+
SA_NOCLDWAIT = 2;
|
|
10633
10648
|
DISPOSITION_IGNORE = 1;
|
|
10634
10649
|
DISPOSITION_HANDLER = 2;
|
|
10635
10650
|
withBit = (mask, bit, on) => on ? mask | bit : mask & ~bit;
|
|
@@ -10646,6 +10661,7 @@ var init_wasi_signals = __esm({
|
|
|
10646
10661
|
ignoring = 0;
|
|
10647
10662
|
restarting = 0;
|
|
10648
10663
|
defaults = 0;
|
|
10664
|
+
nocldwait = false;
|
|
10649
10665
|
fallBack;
|
|
10650
10666
|
onKilled;
|
|
10651
10667
|
constructor(fallBack, onKilled) {
|
|
@@ -10671,6 +10687,7 @@ var init_wasi_signals = __esm({
|
|
|
10671
10687
|
this.ignoring = withBit(this.ignoring, bit, disposition === DISPOSITION_IGNORE);
|
|
10672
10688
|
this.restarting = withBit(this.restarting, bit, (flags & SA_RESTART) !== 0);
|
|
10673
10689
|
this.defaults = withBit(this.defaults, bit, disposition === 0);
|
|
10690
|
+
if (sig === SIG.CHLD) this.nocldwait = (flags & SA_NOCLDWAIT) !== 0;
|
|
10674
10691
|
return E.SUCCESS;
|
|
10675
10692
|
}
|
|
10676
10693
|
snapshot() {
|
|
@@ -10680,7 +10697,8 @@ var init_wasi_signals = __esm({
|
|
|
10680
10697
|
handlers: this.handlers,
|
|
10681
10698
|
ignoring: this.ignoring,
|
|
10682
10699
|
restarting: this.restarting,
|
|
10683
|
-
uncaught: this.uncaught
|
|
10700
|
+
uncaught: this.uncaught,
|
|
10701
|
+
...this.nocldwait ? { nocldwait: true } : {}
|
|
10684
10702
|
};
|
|
10685
10703
|
}
|
|
10686
10704
|
restore(state) {
|
|
@@ -10690,13 +10708,15 @@ var init_wasi_signals = __esm({
|
|
|
10690
10708
|
this.ignoring = state.ignoring;
|
|
10691
10709
|
this.restarting = state.restarting;
|
|
10692
10710
|
this.uncaught = state.uncaught;
|
|
10711
|
+
this.nocldwait = state.nocldwait === true;
|
|
10693
10712
|
}
|
|
10694
10713
|
masks() {
|
|
10695
10714
|
if (this.hooked) {
|
|
10696
10715
|
const caught = this.handler() ? this.handlers : 0;
|
|
10697
10716
|
const defaults = this.defaults;
|
|
10698
10717
|
this.defaults = 0;
|
|
10699
|
-
|
|
10718
|
+
const nocldwait = this.nocldwait ? { nocldwait: true } : {};
|
|
10719
|
+
return { caught, ignored: this.ignoring, restart: this.restarting, defaults, ...nocldwait };
|
|
10700
10720
|
}
|
|
10701
10721
|
if (!this.handler()) return null;
|
|
10702
10722
|
return { caught: DELIVERED_MASK & ~this.uncaught & ~KERNEL_DEFAULTS, ignored: 0, restart: 0 };
|