@ai-ecoverse/slicc-kernel 1.102.5 → 1.103.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.
Files changed (180) hide show
  1. package/README.md +10 -2
  2. package/dist/kernel-worker.js +18 -3
  3. package/dist/kernel-worker.js.map +2 -2
  4. package/dist/node-process-worker.js +1 -1
  5. package/dist/node.js +18 -3
  6. package/dist/node.js.map +2 -2
  7. package/dist/process-worker.js +1 -1
  8. package/dist/types/body-idle.d.ts +3 -0
  9. package/dist/types/bytes.d.ts +1 -0
  10. package/dist/types/cdp/facade.d.ts +27 -0
  11. package/dist/types/cdp/hosts.d.ts +14 -0
  12. package/dist/types/cdp/port.d.ts +24 -0
  13. package/dist/types/cdp/types.d.ts +12 -0
  14. package/dist/types/cdp/websocket.d.ts +61 -0
  15. package/dist/types/client/attach.d.ts +132 -0
  16. package/dist/types/client/dial-stream.d.ts +23 -0
  17. package/dist/types/client/loopback-fetch.d.ts +5 -0
  18. package/dist/types/client/protocol.d.ts +153 -0
  19. package/dist/types/client/serve-client.d.ts +18 -0
  20. package/dist/types/clipboard-relay.d.ts +25 -0
  21. package/dist/types/commands.d.ts +38 -0
  22. package/dist/types/cron/clock.d.ts +13 -0
  23. package/dist/types/driver.d.ts +3 -0
  24. package/dist/types/facade/hosts.d.ts +12 -0
  25. package/dist/types/facade/port.d.ts +16 -0
  26. package/dist/types/facade/types.d.ts +23 -0
  27. package/dist/types/fs/access.d.ts +29 -0
  28. package/dist/types/fs/attest.d.ts +41 -0
  29. package/dist/types/fs/changes.d.ts +19 -0
  30. package/dist/types/fs/commands.d.ts +4 -0
  31. package/dist/types/fs/dac.d.ts +64 -0
  32. package/dist/types/fs/dev-removal.d.ts +9 -0
  33. package/dist/types/fs/fresh-modules.d.ts +9 -0
  34. package/dist/types/fs/integrity.d.ts +53 -0
  35. package/dist/types/fs/meta.d.ts +85 -0
  36. package/dist/types/fs/opfs.d.ts +141 -0
  37. package/dist/types/fs/owners.d.ts +17 -0
  38. package/dist/types/fs/pages.d.ts +41 -0
  39. package/dist/types/fs/path-map.d.ts +16 -0
  40. package/dist/types/fs/physical-path.d.ts +14 -0
  41. package/dist/types/fs/protect.d.ts +27 -0
  42. package/dist/types/fs/ranged.d.ts +73 -0
  43. package/dist/types/fs/remote.d.ts +45 -0
  44. package/dist/types/fs/types.d.ts +115 -0
  45. package/dist/types/fs/unlinked.d.ts +75 -0
  46. package/dist/types/fs/view.d.ts +1 -0
  47. package/dist/types/fs/walk.d.ts +12 -0
  48. package/dist/types/fs/watch.d.ts +23 -0
  49. package/dist/types/index.d.ts +159 -0
  50. package/dist/types/integrity-relay.d.ts +18 -0
  51. package/dist/types/kernel/children.d.ts +90 -0
  52. package/dist/types/kernel/clipboard.d.ts +49 -0
  53. package/dist/types/kernel/cpu-clock.d.ts +56 -0
  54. package/dist/types/kernel/cred.d.ts +17 -0
  55. package/dist/types/kernel/dgram.d.ts +56 -0
  56. package/dist/types/kernel/dial.d.ts +20 -0
  57. package/dist/types/kernel/epoll.d.ts +67 -0
  58. package/dist/types/kernel/eventfd.d.ts +19 -0
  59. package/dist/types/kernel/exec-ticket.d.ts +25 -0
  60. package/dist/types/kernel/fd-table.d.ts +107 -0
  61. package/dist/types/kernel/host-ops.d.ts +98 -0
  62. package/dist/types/kernel/host.d.ts +116 -0
  63. package/dist/types/kernel/jobs.d.ts +50 -0
  64. package/dist/types/kernel/locks.d.ts +40 -0
  65. package/dist/types/kernel/net/datagram-wire.d.ts +8 -0
  66. package/dist/types/kernel/net/http-syscalls.d.ts +58 -0
  67. package/dist/types/kernel/net/http1.d.ts +48 -0
  68. package/dist/types/kernel/net/loopback-names.d.ts +14 -0
  69. package/dist/types/kernel/net/loopback-transport.d.ts +13 -0
  70. package/dist/types/kernel/net/network.d.ts +29 -0
  71. package/dist/types/kernel/net/proxy-service.d.ts +70 -0
  72. package/dist/types/kernel/net/realm-ca.d.ts +28 -0
  73. package/dist/types/kernel/net/redirect-hops.d.ts +5 -0
  74. package/dist/types/kernel/net/remote-transport.d.ts +98 -0
  75. package/dist/types/kernel/net/resolver.d.ts +29 -0
  76. package/dist/types/kernel/net/routes.d.ts +15 -0
  77. package/dist/types/kernel/net/tls-engine.d.ts +46 -0
  78. package/dist/types/kernel/net/tls-tunnel.d.ts +35 -0
  79. package/dist/types/kernel/net/transport.d.ts +64 -0
  80. package/dist/types/kernel/net/uplink-socket.d.ts +11 -0
  81. package/dist/types/kernel/net/uplink.d.ts +163 -0
  82. package/dist/types/kernel/net/ws-queue.d.ts +21 -0
  83. package/dist/types/kernel/net/ws-syscalls.d.ts +45 -0
  84. package/dist/types/kernel/net/x509.d.ts +34 -0
  85. package/dist/types/kernel/pipe.d.ts +29 -0
  86. package/dist/types/kernel/proc-info.d.ts +44 -0
  87. package/dist/types/kernel/process.d.ts +525 -0
  88. package/dist/types/kernel/protocol.d.ts +126 -0
  89. package/dist/types/kernel/pty.d.ts +84 -0
  90. package/dist/types/kernel/run-child.d.ts +39 -0
  91. package/dist/types/kernel/scrub-file.d.ts +13 -0
  92. package/dist/types/kernel/sealed.d.ts +74 -0
  93. package/dist/types/kernel/select.d.ts +7 -0
  94. package/dist/types/kernel/sem.d.ts +72 -0
  95. package/dist/types/kernel/settling.d.ts +16 -0
  96. package/dist/types/kernel/signals.d.ts +44 -0
  97. package/dist/types/kernel/socket-syscalls.d.ts +74 -0
  98. package/dist/types/kernel/socket.d.ts +125 -0
  99. package/dist/types/kernel/timer.d.ts +4 -0
  100. package/dist/types/kernel/tty.d.ts +53 -0
  101. package/dist/types/kernel/vfs-file.d.ts +149 -0
  102. package/dist/types/launcher.d.ts +359 -0
  103. package/dist/types/local-proxy-transport.d.ts +39 -0
  104. package/dist/types/meta.d.ts +11 -0
  105. package/dist/types/mount/chunked.d.ts +9 -0
  106. package/dist/types/mount/connection.d.ts +35 -0
  107. package/dist/types/mount/driver.d.ts +50 -0
  108. package/dist/types/mount/fsa.d.ts +26 -0
  109. package/dist/types/mount/fstab.d.ts +17 -0
  110. package/dist/types/mount/host.d.ts +24 -0
  111. package/dist/types/mount/hostfs.d.ts +129 -0
  112. package/dist/types/mount/media.d.ts +8 -0
  113. package/dist/types/mount/medium.d.ts +12 -0
  114. package/dist/types/mount/mount-fs.d.ts +136 -0
  115. package/dist/types/mount/protocol.d.ts +140 -0
  116. package/dist/types/mount/syscall.d.ts +27 -0
  117. package/dist/types/mount/tmpfs.d.ts +2 -0
  118. package/dist/types/node/loopback.d.ts +11 -0
  119. package/dist/types/node/memory-root.d.ts +2 -0
  120. package/dist/types/node/ws-diagnose.d.ts +4 -0
  121. package/dist/types/node.d.ts +85 -0
  122. package/dist/types/process/fd-metadata.d.ts +4 -0
  123. package/dist/types/process/js/async-sab.d.ts +15 -0
  124. package/dist/types/process/js/js-children.d.ts +63 -0
  125. package/dist/types/process/js/js-context.d.ts +133 -0
  126. package/dist/types/process/js/js-dev.d.ts +50 -0
  127. package/dist/types/process/js/js-exit.d.ts +15 -0
  128. package/dist/types/process/js/js-fetch.d.ts +2 -0
  129. package/dist/types/process/js/js-io.d.ts +81 -0
  130. package/dist/types/process/js/js-kernel.d.ts +61 -0
  131. package/dist/types/process/js/js-net.d.ts +42 -0
  132. package/dist/types/process/js/js-proc.d.ts +31 -0
  133. package/dist/types/process/js/js-run.d.ts +35 -0
  134. package/dist/types/process/js/js-sync.d.ts +86 -0
  135. package/dist/types/process/js/js-tty.d.ts +30 -0
  136. package/dist/types/process/js/js-websocket.d.ts +21 -0
  137. package/dist/types/process/kernel-streams.d.ts +196 -0
  138. package/dist/types/process/process-fds.d.ts +95 -0
  139. package/dist/types/process/process-locks.d.ts +29 -0
  140. package/dist/types/process/process-pty.d.ts +20 -0
  141. package/dist/types/process/process-signals.d.ts +33 -0
  142. package/dist/types/process/procfs.d.ts +41 -0
  143. package/dist/types/process/wasi/dylink.d.ts +9 -0
  144. package/dist/types/process/wasi/slicc-lock.d.ts +26 -0
  145. package/dist/types/process/wasi/slicc-sem.d.ts +3 -0
  146. package/dist/types/process/wasi/wasi-abi.d.ts +156 -0
  147. package/dist/types/process/wasi/wasi-fds.d.ts +130 -0
  148. package/dist/types/process/wasi/wasi-files.d.ts +99 -0
  149. package/dist/types/process/wasi/wasi-host.d.ts +104 -0
  150. package/dist/types/process/wasi/wasi-memory.d.ts +16 -0
  151. package/dist/types/process/wasi/wasi-module.d.ts +13 -0
  152. package/dist/types/process/wasi/wasi-poll.d.ts +13 -0
  153. package/dist/types/process/wasi/wasi-procfs.d.ts +36 -0
  154. package/dist/types/process/wasi/wasi-sigmask.d.ts +19 -0
  155. package/dist/types/process/wasi/wasi-signals.d.ts +43 -0
  156. package/dist/types/process/wasi/wasi-termios.d.ts +10 -0
  157. package/dist/types/process/wasi/wasix-fork.d.ts +63 -0
  158. package/dist/types/process/wasi/wasix-linker.d.ts +108 -0
  159. package/dist/types/process/wasi/wasix-sockets.d.ts +9 -0
  160. package/dist/types/process/wasi/wasix-trampoline.d.ts +18 -0
  161. package/dist/types/process/wasi/wasm-functypes.d.ts +25 -0
  162. package/dist/types/process/wasi-errno.d.ts +1 -0
  163. package/dist/types/realm/emscripten-vfs-hook.d.ts +19 -0
  164. package/dist/types/realm/live-vfs-fs.d.ts +186 -0
  165. package/dist/types/realm/sync-fs-dispatch.d.ts +26 -0
  166. package/dist/types/realm/sync-fs-token-registry.d.ts +36 -0
  167. package/dist/types/realm/sync-fs-wire.d.ts +118 -0
  168. package/dist/types/realm/sync-sab-bridge.d.ts +21 -0
  169. package/dist/types/realm/sync-sab-responder.d.ts +16 -0
  170. package/dist/types/realm/sync-sab-wire.d.ts +64 -0
  171. package/dist/types/sealed-relay.d.ts +26 -0
  172. package/dist/types/serve.d.ts +190 -0
  173. package/dist/types/sudo-command.d.ts +4 -0
  174. package/dist/types/sudo.d.ts +105 -0
  175. package/dist/types/testing.d.ts +46 -0
  176. package/dist/types/transport.d.ts +25 -0
  177. package/dist/types/users.d.ts +86 -0
  178. package/dist/types/version.d.ts +3 -0
  179. package/dist/types/websocket-transport.d.ts +12 -0
  180. package/package.json +22 -6
package/README.md CHANGED
@@ -17,7 +17,7 @@ const { status, stdout, stderr } = await kernel.run(['bash', '-c', 'echo hi > he
17
17
  - **The kernel lives in a dedicated worker owned by the page.** A `SharedWorker` is never cross-origin isolated in Chromium (and has no `Worker` constructor), so it cannot host the kernel. `createKernel` starts `dist/kernel-worker.js`; that worker owns OPFS and starts one nested dedicated worker (`dist/process-worker.js`) per process. The kernel worker reads `process-worker.js` once when it starts and runs every process and thread from that copy (a `blob:` URL), so updating the package in place while a kernel runs does not mix versions: the next page load switches both.
18
18
  - The page's CSP must allow `eval`, since each process evaluates its program's Emscripten glue with `new Function`, and `blob:` workers (`worker-src 'self' blob:`, or the `script-src` it falls back to), since processes run from the kernel's pinned copy of `process-worker.js`.
19
19
 
20
- `dist/` is plain ESM with no bare imports, and the workers are referenced with `new URL('./….js', import.meta.url)`, so the files work when served as-is (for example from OPFS through a service worker). Whatever serves them must send the COOP/COEP headers on the page and a compatible `Cross-Origin-Resource-Policy` on the scripts.
20
+ TypeScript declarations ship in `dist/types/`, and each entry (`.`, `./node`, `./driver`, `./testing`, `./meta`) names its own in `exports` under `types`, so a TypeScript consumer gets the API's types with `moduleResolution` `NodeNext` or `Bundler`. The `./node` entry's types need `@types/node`. `dist/` is plain ESM with no bare imports, and the workers are referenced with `new URL('./….js', import.meta.url)`, so the files work when served as-is (for example from OPFS through a service worker). Whatever serves them must send the COOP/COEP headers on the page and a compatible `Cross-Origin-Resource-Policy` on the scripts.
21
21
 
22
22
  ## API
23
23
 
@@ -311,7 +311,7 @@ On top of preview1 a WASI program gets:
311
311
  - `MAP_SHARED` mappings aren't shared between processes, so unnamed semaphores (`sem_init` with `pshared`) work only between a process's threads, and `multiprocessing.shared_memory` doesn't work.
312
312
  - **Foreign calls** (libffi's WASIX backend, so Python's `ctypes`): `call_dynamic` calls a function through the program's indirect function table (a static module's exported `__indirect_function_table`, or the dynamic linker's), its arguments and results packed in memory one after another (`i32`/`f32` 4 bytes, `i64`/`f64` 8). With `strict` set, the buffers must fit the function exactly (else `EINVAL`, before the function is called); without it, missing arguments are zero (one cut short keeps the bytes given, with zeros above them) and results that do not fit are left out. A trap or exception of the callee goes through to the caller. JS cannot ask a function for its type, so the kernel reads the types from the module files (the program's and each side module's, once, when a program first calls through `call_dynamic`): a table slot that is empty, past the end, holds a function of no module the kernel knows of, or takes or returns a `v128`, gives `EINVAL`. For closures (callbacks such as `CFUNCTYPE`), a dynamically linked program gets table slots from `closure_allocate`, and `closure_free` gives them back for reuse and empties the slot in every thread; a static program gets `ENOTSUP`. `closure_prepare` puts a trampoline with the requested signature (any of `i32`, `i64`, `f32`, `f64`, `v128`) into such a slot, in every thread: each call stores its arguments below the stack pointer and calls the backing function as `backing(values, results, user_data)`, then returns what it wrote to `results`. The trampolines are small wasm modules made and compiled at run time, once per signature in each thread (an instance per closure), so a page whose Content Security Policy forbids compiling WebAssembly (no `'wasm-unsafe-eval'`) cannot run them; it cannot run the program either. A `fork` or a `longjmp` (both through Asyncify) inside a function reached through `call_dynamic` cannot unwind through it.
313
313
  - **Job control:** `^Z`, `SIGTSTP`, `SIGTTIN` and `SIGTTOU` stop a WASIX program at once, unless it has a handler for them. A stopped program that is busy computing is stopped for job control (`jobs` shows it, `fg`, `bg` and `SIGCONT` work), but its worker keeps a core busy until its next system call, since a worker's running code cannot be frozen from outside. Agents should `kill` such a job rather than leave it stopped. An Emscripten program stops at its next kernel call as well, and at its next write, read or sleep that its glue answers without the kernel (a write to its own `/dev/null`, as in `yes > /dev/null`), so a stopped one keeps no core busy unless it computes without any of these calls. A stopped program doesn't move on while stopped: a `sleep` (or a blocked read) that would end meanwhile ends after `SIGCONT`. A call that the stop interrupted runs again after `SIGCONT`, as on Linux. One with a timeout (`select`, `poll`, `ppoll`, `pselect`, `nanosleep`, a timed semaphore wait) waits only for the time that's left, counted from when the kernel first got the call, so it still ends at its deadline. `epoll_wait` and `epoll_pwait` aren't run again: they fail with `EINTR`, even without a handler (signal(7)). A signal for such a program is also delivered at those glue-answered calls, so a handler runs in a loop that only writes to `/dev/null`. For the same reason, a signal with a handler or a terminating default (`^C`, `SIGTERM`) reaches a program that is busy computing only at its next system call, so a CPU-bound loop may not end on `^C`; `kill -9` always ends it. A pending signal is delivered at the program's next WASI or WASIX call, including the calls its worker answers without the kernel (`random_get`, `args_get`, …), except the exempt ones: `clock_time_get` (a tight loop of it measured up to 30% slower), `proc_exit`, `proc_exit2`, `thread_exit`, `thread_spawn_v2` and `wasi.thread-spawn` (wasi-threads), the calls that install handlers (`callback_signal`, `slicc.sigaction_set`), and calls made while Asyncify unwinds or rewinds the stack for `fork` or `longjmp`. A signal that arrives while a thread computes is thus delivered at its next call; when that call is a wait (`poll_oneoff` with a timeout or a descriptor, so `nanosleep` and `poll`/`select` too, `sigmask_poll`, or a futex wait), the handler has run during the call, so the wait ends at once: `EINTR` for a libc of -22 or later (an older one sees its clocks fire, as for any interruption), and a futex wait returns woken. A thread blocked in the kernel or waiting on a lock (`pthread_cond_wait`, a futex) is woken by a signal for it (a futex wait checks for signals every 50 ms, so each waiting thread wakes briefly that often), and `pthread_kill` runs the handler on the thread it names. A sleep, or a clock in `poll_oneoff`, never ends before the time asked (it can end later, never earlier). A signal that ends a sleep or a `poll`/`select` with a timeout makes the call fail with `EINTR` in a program whose libc says it is wasix-sysroot 2025.9.30-22 or later (its `slicc.libc` custom section). Older libcs turn that answer into `ENOTSUP` from `nanosleep` (up to -18), so for a program without the section the wait ends as if it had timed out, unless it imports `fd_fdflags_set` (then `EINTR`, as before).
314
- - **Blocked signals** (`sigprocmask`, `pthread_sigmask`, `sigpending`): a program whose libc imports `slicc.sigmask_set(how, set_lo, set_hi, old_ptr)` and `slicc.sigpending_get(ptr)` (wasix-sysroot 2025.9.30-28 and later) has a blocked mask per thread. `how` is musl's `SIG_BLOCK` 0, `SIG_UNBLOCK` 1 or `SIG_SETMASK` 2, the set is the 64-bit `sigset_t` (bit `sig - 1`), and the old mask is written as a u64 at `old_ptr`; any other `how` is `EINVAL`. `SIGKILL` and `SIGSTOP` cannot be blocked. A blocked signal is not delivered, does not interrupt a sleep or a blocked call, and its default action (terminate or stop) waits: it stays pending, `sigpending` shows it (the thread's pending signals and the process's), and it is delivered when it is unblocked, before `sigmask_set` returns. A signal ignored with `SIG_IGN` is discarded even while blocked. A forked child (with the mask of the thread that forked), the program an `exec` starts and a spawned child keep the mask, all 64 bits of it, and so does a new thread; `/proc/<pid>/status` shows the main thread's as `SigBlk`. The mask is kept in a word of the worker's shared header, so changing it costs no kernel call. A program without the import (an older libc) has no mask and gets every signal at once, as before, and one it starts by `exec` with a mask set starts with none. A signal for the whole process goes to the main thread, even if the main thread blocks it and another thread does not. A signal sent to one thread (`pthread_kill`) that it blocks waits for that thread, and if it has no handler, the thread's unblock ends the whole process by the signal, whatever the other threads block. `slicc.sigmask_poll(set_lo, set_hi, in_ptr, out_ptr, nsubscriptions, nevents_ptr)` is `pselect`, `ppoll` and `sigsuspend`: it swaps the thread's mask to the given set for the call and puts the old one back before it returns. It delivers a pending signal the new mask unblocks, without polling, or polls as `poll_oneoff` does, under the new mask, so a signal it unblocks interrupts the wait with no window between the swap and the wait; with no subscriptions it waits until a signal is delivered. An interrupted call returns `EINTR` with no events, after the handler has run.
314
+ - **Blocked signals** (`sigprocmask`, `pthread_sigmask`, `sigpending`): a program whose libc imports `slicc.sigmask_set(how, set_lo, set_hi, old_ptr)` and `slicc.sigpending_get(ptr)` (wasix-sysroot 2025.9.30-28 and later) has a blocked mask per thread. `how` is musl's `SIG_BLOCK` 0, `SIG_UNBLOCK` 1 or `SIG_SETMASK` 2, the set is the 64-bit `sigset_t` (bit `sig - 1`), and the old mask is written as a u64 at `old_ptr`; any other `how` is `EINVAL`. `SIGKILL` and `SIGSTOP` cannot be blocked. A blocked signal is not delivered, does not interrupt a sleep or a blocked call, and its default action (terminate or stop) waits: it stays pending, `sigpending` shows it (the thread's pending signals and the process's), and it is delivered when it is unblocked, before `sigmask_set` returns. A signal ignored with `SIG_IGN` is discarded even while blocked. A forked child (with the mask of the thread that forked), the program an `exec` starts and a spawned child keep the mask, all 64 bits of it, and so does a new thread; `/proc/<pid>/status` shows the main thread's as `SigBlk`. The mask is kept in a word of the worker's shared header, so changing it costs no kernel call. A program without the import (an older libc) has no mask and gets every signal at once, as before, and one it starts by `exec` with a mask set starts with none. A signal for the whole process goes to the main thread, unless the main thread blocks it and another thread does not. Then, as on Linux, it goes to that thread: its handler runs there, or with no handler its default action ends (or stops) the whole process at once. So the "signal thread" pattern works: block in main, unblock in a worker (#520). It waits on the main thread only when every thread blocks it. A signal sent to one thread (`pthread_kill`) that it blocks waits for that thread, and if it has no handler, the thread's unblock ends the whole process by the signal, whatever the other threads block. `slicc.sigmask_poll(set_lo, set_hi, in_ptr, out_ptr, nsubscriptions, nevents_ptr)` is `pselect`, `ppoll` and `sigsuspend`: it swaps the thread's mask to the given set for the call and puts the old one back before it returns. It delivers a pending signal the new mask unblocks, without polling, or polls as `poll_oneoff` does, under the new mask, so a signal it unblocks interrupts the wait with no window between the swap and the wait; with no subscriptions it waits until a signal is delivered. An interrupted call returns `EINTR` with no events, after the handler has run.
315
315
  - **Pipes** have no file type for WASI and WASIX programs' `fstat` (`st_mode` type 0), because WASI has no FIFO file type. A socket type, as kernels 1.47.3 to 1.48.1 gave them, made Ruby treat a `popen` pipe as a socket (`close_write` then never ends the child's input). The kernel's `slicc_fs.fd_mode` answers `S_IFIFO | 0600` (Linux numbering) for a pipe, and wasix-sysroot 2025.9.30-21 and later take the type from it, so programs built on it see a FIFO (`S_ISFIFO`); older libcs keep only the permission bits. Until then Python's asyncio refuses a pipe for a subprocess (`Pipe transport is only for pipes, sockets and character devices`). They are read and written as pipes; socket calls on them fail with `ENOTSOCK`, and `isatty()` is false. Emscripten programs, bash included, see a FIFO. The same holds for any kernel descriptor that is neither seekable nor a terminal or device, such as captured output.
316
316
  - **Sockets**: the WASIX socket calls (`sock_open`, `sock_pair` for an `AF_UNIX` stream pair, `bind`, `listen`, `connect`, `accept`, options, local and peer names) are the kernel's loopback sockets, and preview1's `sock_recv` / `sock_send` / `sock_shutdown` work on them and on inherited ones. Writing to a socket whose peer is gone fails with `EPIPE`, through `fd_write` as through `sock_send`, as if `MSG_NOSIGNAL` were set, since a WASI program cannot ignore `SIGPIPE`; a pipe or terminal whose reader is gone still ends the program with status 141. HTTP and HTTPS leave through the realm proxy that `https_proxy` names, as for any other program; `resolve` answers `/etc/hosts` names and literal addresses, and the [uplink](#uplink)'s names. `sock_open(SOCK_DGRAM)` on `AF_INET`/`AF_INET6` gives a [datagram socket](#datagram-sockets-udp); `sock_send_to` and `sock_recv_from` carry its addresses, and `RECV_DATA_TRUNCATED` is set in `ro_flags` when a datagram did not fit.
317
317
  - **Diagnostics**: a trap ends the program with 134 and its message on stderr; with `SLICC_WASM_BACKTRACE=1` the wasm frames follow, named from the module's name section, or from a sidecar for a module shipped without one (`<module>.names` beside it, or the same path in a `<package>-names` package). `SLICC_WASI_STATS=1` makes a program print its calls, counted and timed, as it ends.
@@ -1032,6 +1032,14 @@ A WASIX C program for `test/integration/stop-restart.test.mjs` (#738). `stopwait
1032
1032
 
1033
1033
  **Build:** `WASIX_SYSROOT_28=/path/to/wasix-sysroot ./build.sh`, with `wasixcc` 0.4.7 (legacy exceptions) and binaryen's `wasm-opt` (`--asyncify` for `proc_fork`) on `PATH`. `bin/stopwait.wasm` is 59,958 bytes, sha256 `ce49e04baed13b7ccf04d8231da4a29567fde0dac19d5cc81f36c185e0eb4555`.
1034
1034
 
1035
+ ### `sigthread`
1036
+
1037
+ A threaded WASIX C program for `test/integration/thread-signal.test.mjs` (#520). The main thread blocks `SIGUSR1` and `SIGTERM`, and a worker thread unblocks both. Then the program signals itself:
1038
+ - `sigthread handler` sends `SIGUSR1` (with a handler) and prints which thread ran the handler;
1039
+ - `sigthread default` sends `SIGTERM` (no handler), which must end the process.
1040
+
1041
+ **Build:** `WASIX_SYSROOT_28=/path/to/wasix-sysroot ./build.sh`, with `wasixcc` 0.4.7 (`-pthread`) and binaryen's `wasm-opt` on `PATH`. `bin/sigthread.wasm` is 44,788 bytes, sha256 `5781fa39d0a0032cd9b214b71de1f15f589b40e4cecd6862362048dd27f0db56`.
1042
+
1035
1043
  ### `longwait`
1036
1044
 
1037
1045
  A WASIX C program for `test/integration/long-timers.test.mjs` (#767).
@@ -12184,7 +12184,7 @@ var PATH_OPS = new Set(SYNC_FS_OPS);
12184
12184
  var EARLY_WHOLE_FILE = 64 * 1024;
12185
12185
 
12186
12186
  // src/version.ts
12187
- var KERNEL_VERSION = true ? "1.102.5" : "0.0.0-dev";
12187
+ var KERNEL_VERSION = true ? "1.103.0" : "0.0.0-dev";
12188
12188
  var OS_RELEASE = "6.0.0-slicc";
12189
12189
  function procVersion() {
12190
12190
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -15996,8 +15996,15 @@ var WasmProcess = class {
15996
15996
  const bit = sigbit(sig);
15997
15997
  if (this.ignores(bit)) return "ignore";
15998
15998
  if (((this.options.blockedBits?.() ?? 0) & bit) !== 0) {
15999
- this.options.onPending?.(sig);
16000
- return "deliver";
15999
+ const tid = this.options.unblockedThread?.(sig);
16000
+ if (tid === void 0) {
16001
+ this.options.onPending?.(sig);
16002
+ return "deliver";
16003
+ }
16004
+ if (this.caught & bit) {
16005
+ this.options.threadKill?.(tid, sig);
16006
+ return "deliver";
16007
+ }
16001
16008
  }
16002
16009
  if (!(this.caught & bit)) {
16003
16010
  const action = defaultAction(sig);
@@ -17240,6 +17247,12 @@ function killThread(thread, caught, sig) {
17240
17247
  blocked2.abort();
17241
17248
  return true;
17242
17249
  }
17250
+ function unblockedThread(threads, sig) {
17251
+ for (const [tid, thread] of threads) {
17252
+ if ((Atomics.load(thread.header, SAB_I_BLOCKED) & sigbit(sig)) === 0) return tid;
17253
+ }
17254
+ return void 0;
17255
+ }
17243
17256
  function unblocked(header3) {
17244
17257
  return Atomics.load(header3, SAB_I_SIGNALS) & ~Atomics.load(header3, SAB_I_BLOCKED);
17245
17258
  }
@@ -17390,6 +17403,7 @@ function processOptions(opts, header3, hooks, created3) {
17390
17403
  hasPending: () => unblocked(header3) !== 0 || Atomics.load(header3, SAB_I_TIMERS) !== 0,
17391
17404
  raise: hooks.raise,
17392
17405
  threadKill: hooks.threadKill,
17406
+ unblockedThread: hooks.unblockedThread,
17393
17407
  ...hooks.exitNow ? { exitNow: hooks.exitNow } : {},
17394
17408
  ...hooks.exitSignal ? { exitSignal: hooks.exitSignal } : {},
17395
17409
  ...opts.program.abi === "wasi" || opts.program.abi === "js" ? { pendingBits: () => Atomics.load(header3, SAB_I_SIGNALS) } : {},
@@ -17430,6 +17444,7 @@ function spawnWasmProcess(opts) {
17430
17444
  {
17431
17445
  raise: (sig) => signal(sig),
17432
17446
  threadKill: (tid, sig) => killThread(threadSignals.get(tid), process.signalMasks().caught, sig),
17447
+ unblockedThread: (sig) => unblockedThread(threadSignals, sig),
17433
17448
  ...opts.program.abi === "js" ? {
17434
17449
  exitNow: (code) => exitNow(code),
17435
17450
  exitSignal: (sig) => queueMicrotask(() => finish(128 + sig, sig))