OptionalonCalled when a process calls clone (thread creation). The callback should spawn a thread Worker sharing the parent's Memory. Returns the TID.
OptionalonCalled when a process calls execve. The callback should resolve the program path, terminate the old Worker, create a new Worker with the new binary, and call registerProcess with skipKernelCreate. Returns 0 on success, negative errno on error.
OptionalonCalled when a process exits.
OptionalonCalled when a process calls exit_group (terminate all threads). The callback should forcefully terminate all thread workers for the process. Called BEFORE the process exit is processed.
OptionalonCalled when a process forks. The kernel has already cloned the Process in its ProcessTable. The callback should spawn a child Worker with a copy of the parent's Memory and register it with the kernel. Returns the channel offsets allocated for the child.
threadFork is set when the parent issued the fork() syscall from a
thread spawned via pthread_create (i.e. on a channel registered
through addChannel(pid, offset, tid, fnPtr, argPtr) with tid > 0).
The host must:
forkBufAddr (not the main channel's) for the
child's rewind so the saved frames + saved __tls_base /
__stack_pointer match what the parent thread populated, andfnPtr/argPtr)
directly instead of _start — _start is not in the thread's
fork-path call chain and rewinding through it would never reach
the saved fork() call site.If threadFork is omitted the callback handles the fork as a
fork-from-main-thread (the existing path).
OptionalonPre-flight resolution step for SYS_SPAWN. Returns the program bytes
for path (or { programBytes, argv } when resolution rewrites argv,
e.g. a shebang script), { errno } for a located but unlaunchable
program, or null for ENOENT. Must NOT have side effects —
handleSpawn calls this BEFORE kernel_spawn_process so that file
actions never run on a doomed PATH-iteration. POSIX requires
file_actions to run "exactly once," and posix_spawnp's PATH-walk
issues one posix_spawn per candidate; without this preflight the
kernel applies file_actions on every failed iteration (sortix
basic/spawn/posix_spawnp exercises an addopen(O_EXCL) "once"
file that would conflict on iteration 2).
Required if onSpawn is set; together they form the spawn surface.
OptionalonLaunch a worker for the spawned child with already-resolved bytes
and argv (from onResolveSpawn). The kernel has constructed the child Process
descriptor under childPid and applied file actions + attrs by the
time this is called. The callback instantiates a fresh Worker and
registers it via registerProcess({ skipKernelCreate: true }).
Returns 0 on success, negative errno on failure. On non-zero return
the kernel descriptor is rolled back via kernel_remove_process.
Distinct from onExec (which replaces the calling worker) and
onFork (which clones the parent's Memory): onSpawn always
creates a fresh Memory and runs the new program from _start.
OptionalonCalled after a pthread channel reaches SYS_EXIT and the kernel worker has performed the musl clear-TID wake used by pthread joiners. Return true when the host will terminate the backing Worker, so the syscall channel should not be completed back into guest code.
Callbacks for fork/exec/exit handling.