Native processes, loading, and the C runtime

Syscall and service boundaries

The kernel exposes IPC and privileged mechanisms such as mapping, thread control, and interrupt acknowledgement. The native dispatch selector is reserved separately from foreign syscall numbers. The architecture-specific stubs for these operations live in libsys, with public ABI declarations in common/include/. Native userspace services own processes, credentials, signals, file descriptors, executable loading, and other POSIX objects.

The C headers native_call.h and native_ipc.h declare the C-linkage libsys_* functions. The typed C++ wrappers share the same operation numbers and message layout. The kernel target defines _KERNEL to hide userspace stub declarations. Servers and libraries under packages/servers/ can use the same userspace IPC interfaces as other callers. See Porting external software for using these APIs in an external port.

libc implements POSIX calls using the services that own those objects. For example, VFS resolves and authorizes open(). The resulting handle can authorize a direct call to the filesystem server for read() or write(). Bulk I/O uses capability-controlled shared memory. Native process interfaces should preserve POSIX lifecycle, wait, credential, and signal semantics across service boundaries. Target SUSv5/POSIX.1-2024, with support and optional features tracked by architecture and environment.

Server and application startup

Every system server and userspace driver links libsys.a statically. A shared freestanding startup object under packages/servers/common/lib/ passes the service-specific startup data to the server’s main() and exits with its return status. The root task has its own fixed bootstrap layout. Static linking makes resident boot and recovery images independently loadable. See Boot, platform handoff, and service recovery.

For a resident server, the loader checks ELF64 class, System V OSABI, byte order, machine, and ABI flags against the target architecture. System’s GCC userspace builds disable GNU unique symbol binding so GNU binutils emits the System V OSABI required by the loader. The server format supports RV64, AMD64, ARM64, and PowerPC64 ELFv2 in both byte orders. Validation finishes before the first segment is mapped. The resident root supervisor and VM server run on RISC-V, AMD64, and ARM64 and both PowerPC64 byte orders. Native syscall stubs enter through ecall, int $0x80, svc #0, or sc respectively. Kernel architecture code translates the saved trap state into the shared native message ABI. The application debugger profiles support statically linked native programs on each of these architectures and use an integer-only bootstrap libc on the non-RISC-V targets. The runtime interpreter and shared base libraries currently use the RISC-V ABI.

LinuxKPI driver processes also link liblinuxkpi.a statically. See Platforms, device drivers, and virtualization for the coordinator and driver-library boundary.

struct server_start_t

Initial register words. Each server defines the meaning of its slots.

Ordinary applications enter through an application CRT. The loader maps the image and supplies the ABI-defined initial stack with argc, argv, environment strings, and an auxiliary vector. The CRT publishes environ, calls main(int argc, char **argv), and forwards its exit status. The native auxiliary vector can carry capabilities granted to the new process.

Native disk applications start with a 16 KiB stack. An ELF PT_GNU_STACK segment can request a larger stack through its memory size. The loader rounds up to a page and accepts sizes up to 1 MiB. The stack is writable and non-executable. PREVAIL requests 128 KiB for the verifier’s debug-build call depth.

The supervisor owns the real, effective, and saved UID and GID of each process. Native init starts with UID and GID 0. Shell commands initially use UID and GID 1000 and pass their current identities to spawned children. Libc queries and changes credentials through the process service using getuid(), geteuid(), getgid(), getegid(), setuid(), seteuid(), setgid(), and setegid().

The supervisor publishes each effective UID and GID as one atomic word in a read-only VFS mapping. VFS selects the word with the authenticated session badge and snapshots it for each pathname operation. The ESP’s directories are searchable and readable by all users. Opening an ESP regular file requires effective UID 0. After a credential change, an already open descriptor retains its authority until closed. Spawn and fork preserve ESP regular-file descriptors for children with effective UID 0. Supplementary groups and set-ID executables remain later work.

struct native_aux_t
struct native_credential_t

Static and shared applications

Programs on the native root link dynamically with libc.so and libsys.so, including init, getty, login, both disk shells, and the base utilities. They link fixed-address executables with position-independent code, which accesses shared data through the global offset table. This avoids copy relocations. The runtime interpreter, resident services and drivers, and the standalone ISO shell and hello probe use static linking so they can start without the native root’s shared libraries. The interpreter links the native syscall stubs and freestanding startup and memory code.

The libsys-shared and libc-shared targets build libsys.so and libc.so. libsys.so exports the native syscall and IPC stubs and is the only dynamic dependency of libc.so. The application CRT calls main() and initializes the environment through libc. The shared libraries live in the shared/ subdirectory of the architecture and mode output directory and in /lib on the native root.

The native root also installs /lib/libc.a and /lib/libsys.a for static linking. The image builder copies these archives intact. It removes unneeded debug and static symbol sections from the disk copies of ELF programs and shared libraries. The build artifacts retain the symbols selected by the build mode. For exec and spawn from the native filesystem, the supervisor validates up to 32 program headers per file and maps the loadable ranges of the executable, interpreter, and base shared libraries through a page-sized VFS buffer. Boot assets that require whole-file access use the supervisor’s bounded 1 MiB staging area.

On RV64, xmake build native-sdk stages the public headers, relocatable crt1.o, base libraries, interpreter, and the LLVM C++ and compiler runtimes under the architecture and mode output directory. The staged tree follows the native /lib, /libexec, /usr/include, and /usr/lib layout. The SDK fixture compiles and links a C++ program using this tree and runs it on the native disk. It links the llvm-demangle archive built from the pinned upstream source. The SDK linker script resolves -lm to the math functions in libc.so.

For a native executable launched from the native root, the supervisor accepts an ELF PT_INTERP naming /libexec/ld-system.so on the native root. It maps the interpreter as a static ELF in the new address space and starts at the interpreter’s entry point. The stack publishes the application entry and mapped program-header table through AT_ENTRY, AT_PHDR, AT_PHNUM, and AT_PHENT. The fixed-address interpreter has zero load bias. For a dynamically linked executable, the supervisor maps the two installed base libraries into reserved address ranges and passes their bases to the interpreter. The interpreter resolves symbols from the SysV dynamic symbol tables and eagerly applies the selected ABI’s relative, absolute, global-data, and procedure-linkage relocations within writable segments. It then seals the linker’s GNU RELRO pages through a protection-only capability before branching to the application entry. The QEMU fixture calls both shared libraries from an ELF loaded off disk. The executable CRT runs preinit and init arrays after installing TLS. Normal exit invokes registered C and C++ callbacks in reverse registration order and then runs the executable’s fini array in reverse order. _exit() terminates directly. Additional libraries, shared-library constructors, PIE, and symbol versioning remain runtime work.

The native dl_iterate_phdr() reports the executable, libc, and libsys using the program headers already validated by process startup. Native applications link with an ELF unwind header when they contain DWARF unwind records. The RV64 LLVM libunwind.a uses that iterator to walk mapped frames. The first build uses the static unwinder with dynamic-symbol lookup and runtime frame registration from concurrent threads outside its support scope.

The RV64 libc++ bootstrap links static libc++.a, libc++abi.a, and libunwind.a into an executable that uses the two base shared libraries. It supports narrow and wide strings, C and POSIX locale facets, regular expressions, streams, containers, threading, and C++ exceptions with stack cleanup on unwind. Its steady clock uses native CLOCK_MONOTONIC. File streams accept string paths. Libc++’s std::filesystem is disabled in this build. The installed headers and archives share the same configuration. Libc runs C++ thread-local destructors in reverse registration order when a worker returns or the calling thread invokes exit(). The runtime keeps the executable and shared libraries mapped for the process lifetime.

The initial RISC-V thread uses Variant I TLS. The supervisor validates each PT_TLS template, maps its initialized data and zero-fill into a writable page for the initial thread, and retains a read-only copy for future threads. An auxiliary vector entry identifies which template slots are present in the address space. The application CRT sets tp to the start of the executable’s TLS slot. The base libraries use their own slots above it. The interpreter resolves RV64 module, dynamic thread-vector, and thread-pointer relocations for these three objects. This covers the local-exec, initial-exec, and general-dynamic relocations used in the supported startup scope. The kernel supports additional raw workers with caller-supplied TLS and stack mappings. Dynamically loaded TLS modules remain later work.

AMD64, ARM64, and PowerPC64 use initial-exec TLS for the base shared libraries. The kernel installs the thread pointer before entering the interpreter, even when only a shared library has a TLS template. The static debugger profiles use local-exec TLS. On AMD64 the template precedes the thread control block, which starts with its own address. ARM64 places the template after the thread control block and aligns it to the ELF template requirement. PowerPC64 applies the ELFv2 thread pointer bias. Worker startup copies and initializes a private TLS image. Fork restores the saved stack and thread pointers, including when the caller was interrupted inside a function.

Native application stacks are owned by the supervisor’s ELF loader. It maps a 16 KiB writable stack and a page of startup vectors above it. The kernel validates the aligned stack pointer and its writable backing when starting the task. On RISC-V the kernel maps a default stack for boot services near the top of user space, away from their loaded ELF segments. The root task retains its fixed bootstrap layout.

Native libc provides application startup, basic string and byte operations, and write() for inherited standard output and standard error as well as connected Unix stream sockets. It supports wide string search and bounded comparison alongside wide memory operations. The locale interfaces support the equivalent C and POSIX locales, including per-thread selection with uselocale() and numeric conventions through localeconv(). The System libc++ configuration uses the messages facet fallback until libc provides message catalogs. Native narrow and wide floating-point conversion uses LLVM libc’s numeric parser and compiler-rt’s RV64 software arithmetic. The runtime uses the console capability supplied in the initial stack. errno uses thread-local storage in both runtime variants. Applications granted a file session can use open(O_RDONLY), read(), pread(), lseek() with SEEK_SET, SEEK_CUR, or SEEK_END, dup(), dup2(), and close() for regular files. fstat() queries a descriptor’s metadata on the native root or mounted ESP. stat() queries regular files and directories in the client’s permitted trees. lstat() also reports metadata for a symbolic link at the final component. fstatfs() reports the filesystem associated with an open descriptor. readlink() reads the target of a terminal symbolic link. realpath() resolves symbolic links explicitly. Implicit traversal by operations such as open() remains pending. eaccess() checks the current effective user, primary group, and supplementary groups. Native processes can change their working directory with chdir() and read it with getcwd(). Threads share the process’s working directory. A spawned child starts in its parent’s directory and changes its own copy independently. See Filesystems, block storage, and networking for lookup and search permissions. VFS owns descriptor flags and offsets and serves descriptor duplication and flag requests from fcntl(). The initial file table has 24 descriptor numbers and eight independent open file descriptions per session. The descriptor range lets a shell keep internal descriptors above the usual redirection range. VFS provides /dev/null with EOF on read and discarded writes, checks the access mode of each open description, and identifies the device separately from the serial terminal.

The initial byte-oriented standard streams are unbuffered and use the process’s inherited descriptors for standard input, output, and error. fdopen() attaches to an existing descriptor with a compatible access mode. Streams track EOF and errors and support one byte of pushback. The formatted output implementation covers integer, pointer, and narrow character and string conversions, including widths and precisions. swprintf() shares the integer formatter and accepts narrow and wide character and string operands in the C locale. Stream orientation selects byte or wide character I/O on first use. Wide streams encode ASCII and report EILSEQ on invalid input or output. They share the stream’s single-byte pushback and support fseeko() and ftello(). Floating-point formatting and standard I/O buffering are pending. fwopen() provides an unbuffered, write-only stream over a callback. This lets the shell format text into its own output buffer using the same formatter used by libc programs. funopen() also supports read, seek, and close callbacks. open_memstream() provides a seekable output stream. The caller owns the buffer after closing it.

Libc initially supports the C locale and its POSIX alias. Byte and wide character classes use ASCII, and conversion rejects invalid bytes with EILSEQ. Locale selection honors the standard environment precedence and rejects unavailable locales. The locale-specific character, collation, and numeric conversion calls use the corresponding C tables. Calendar conversion uses UTC and strftime_l() formats the C locale using the formatter adopted from FreeBSD’s tzcode. Time zone rules, Unicode locale data, and locale-dependent collation are pending. The runtime copies inherited environment strings when the process first changes them with setenv() or unsetenv(). Changes affect subsequent lookups and the environment array that callers pass to execve(). Directory records include the byte length used by the shell’s filename patterns. Standard stream lifetime and writable files remain later work.

clock_gettime(CLOCK_MONOTONIC) reads the kernel’s monotonic counter. Libc converts ticks using the frequency in the process auxiliary vector. clock_getres() reports the counter period rounded up to nanoseconds. Wall-clock services and other clock IDs remain later work.

Native init and ordinary shell-launched applications receive a VM capability for sparse private anonymous mmap and munmap. See Virtual memory for the arena, supported protections, and lifetime.

These applications can start joinable workers in both static and shared libc with pthread_create(), pthread_self(), pthread_equal(), and pthread_join(). Native pthreads map 1:1 to kernel threads. The optional userspace task scheduler for servers runs on top of kernel threads and has its own task handles. See Scheduling and CPU accounting. Each pthread worker receives a stack and an independent TLS area initialized from the ELF templates. A join collects the routine’s return value and releases its stack and TLS pages. Threads share the process’s VFS session, and libc serializes operations that use that session’s transfer page. Workers start with a 16 KiB stack by default. Attributes can request a larger anonymous stack in the process’s VM arena or create the worker already detached. The VM mapping rounds up to whole pages. The boot runtime provides up to six worker slots.

The POSIX sched_* process calls use a badged request to the native process supervisor. The request carries an operation, a PID (zero means the caller), and packed scheduling parameters. The reply carries a status, the prior policy and priority, and the RR interval in monotonic ticks. The supervisor resolves the PID and checks credentials before using a kernel task-management capability to update the base class. Ordinary callers can query processes with the same effective UID and set their own timeshare or idle policy. Effective UID 0 can set real-time priorities and change another process. Fork, spawn, and exec preserve the base policy. See Scheduling and CPU accounting for class precedence and accounting.

struct native_schedule_t

The process’s base scheduling policy and priority.

Process-private mutexes support normal, recursive, and error-checking types. An uncontended normal mutex uses an atomic acquisition. Contended mutexes and one-time initialization yield to the scheduler. Thread-specific keys carry a generation so a reused key cannot see a deleted key’s values. Returning workers clear each value before its destructor and repeat destructor passes up to four times. Condition waits register a private kqueue user event, release the predicate mutex, and sleep in the native event service. Signaling selects one waiter and broadcasting selects every waiter. Timed waits use the condition’s realtime or monotonic clock. Each waiter holds one event queue while blocked, so the native descriptor limits also bound concurrent condition waits.

pthread_detach() transfers cleanup ownership from the joiner to a running worker. After running the TLS destructors, the worker leaves userspace through a final bounded IPC call. The kernel uses the worker’s VM capability for the call. The VM server can unmap the user stack and TLS while the worker is on its kernel stack. The scheduler releases the kernel stack after switching away. If the VM call fails, the VM mapping remains subject to process teardown. A detach that races with a claimed join returns EBUSY. A detach of a returning worker collects its exit and reclaims its mapping directly. Stack guards and cancellation remain later work.

The initial shell can run up to two applications from /bin or /sbin/sysctl on the native root. The shell accepts either sysctl or its absolute path. The supervisor authenticates the shell’s IPC badge, copies the bounded argument vector from a shared page, validates the command, and checks execution permission through VFS. The loaded application receives console output authority, a private file session, and an independent executable image with its own initial stack. The shell can append & after a space to run a command in the background. It uses the returned process ID to collect a foreground child’s exit status. The supervisor assigns PID 1 to boot init and PID 2 to the initial shell. Both report parent PID 0 because the boot supervisor is outside the native process table. The supervisor reserves a PID before starting each shell child and gives that child the same PID used by waitpid(). Libc reads the assigned PID from the auxiliary vector for getpid(). getppid() reads the current parent from the supervisor when the process has a process-service capability. The shell’s child scope ends when the shell exits.

wait4() can return the collected child’s user and system CPU time, including descendants it has already reaped. It returns the usage in the same IPC reply as the process ID and wait status. A nonblocking wait with no event leaves the output arguments untouched. The current resource-usage interface reports CPU time. clock() reports the calling process’s combined user and system CPU time in microsecond ticks.

sysctlbyname("kern.proc", ...) returns a point-in-time array of native_process_info records from the process supervisor. It includes active, stopped, and unreaped processes, with PID, parent, process group, session, credentials, and the executable basename. Argument text is bounded and visible to root and the process’s own UID. An undersized buffer reports the required length without copying a partial record. The query is read-only and uses the caller’s existing process capability.

struct native_process_info

One live or unreaped native process at the time of a snapshot.

Ordinary applications can use posix_spawn() to start unprivileged children from /bin or run /sbin/sysctl. The supervisor looks up the executable under the login credential and starts it with a separate address space. The caller supplies bounded argument and environment vectors through its own transfer page. The supervisor copies the request before loading the executable and builds the child’s initial stack. A null environment pointer supplies an empty environment. Libc exposes the child’s environment through environ and getenv(). Existing file descriptors are inherited at their original numbers with the same open descriptions, except descriptors marked close-on-exec or close-on-fork. The initial implementation accepts default spawn attributes and no file actions. Orphaned processes are adopted by the shell during this bootstrap stage.

waitpid() supports a specific direct child or any direct child, with optional WNOHANG. wait() blocks for any child. Each parent can have one blocking wait outstanding. The supervisor reaps the task, closes its remaining file handles, clears its shared page, and retains the exit status until delivered to the parent. The kernel reports whether the task exited normally, was stopped, or died from a machine exception. The supervisor maps that reason to the native wait status, including the corresponding signal number for a fatal fault. Process IDs are unique during the shell’s lifetime. The ESP stays outside this execution scope.

The native RV64 ptrace() API uses process IPC. A debugger can attach to an authorized process and use waitpid() to receive its debugger stops, including when the traced process is not its child. The supervisor keeps those events separate from ordinary child and job-control events. See Application debugging with ptrace.

Parents may probe their live children with kill(pid, 0) or send SIGHUP, SIGINT, SIGTERM, SIGUSR1, SIGUSR2 and SIGKILL. An ordinary application receives a badged process capability and can also use those operations on itself. The supervisor authenticates the caller from the IPC badge and uses its task capability to stop the target and drain its threads. It reports the selected signal in the child’s wait status after reaping it. A user process can block the supported catchable signals using sigprocmask(). The supervisor coalesces pending instances by signal number, reports them through sigpending(), and lets one waiter consume them with sigwait(). Unblocking a pending signal applies its default action. Spawned children inherit the mask with an empty pending set. The bootstrap mask is process-wide. The shell’s kill builtin accepts a numeric signal and a PID or job reference, with SIGTERM as the default. Native session and job-control semantics are described below.

FreeBSD’s echo and pwd build as C from contrib/freebsd-base. Echo uses the native writev() and supports FreeBSD’s -n and trailing backslash-c options. Pwd checks the path in PWD against the current directory inode for logical mode and supports physical mode through getcwd(). The snapshot also supplies true and false for /usr/bin.

The FreeBSD cat port copies named files and reads standard input when the file list is empty or an operand is -. It supports line numbering, blank-line squeezing, and control-byte display. Output locking requires advisory file locks.

The FreeBSD ls port uses native directory streams and file metadata. It defaults to the current working directory and prints sorted names one per line. Use ls / to list the root from a login home. Long listings display numeric modification times. See Filesystems, block storage, and networking for directory streams and mount visibility.

Static and shared libc use MIT-licensed snmalloc 0.7.6 from contrib/snmalloc/ for malloc, free, calloc, realloc, aligned_alloc, and posix_memalign. The adapter initializes the allocator on first use with a 64 MiB private anonymous reservation and per-process entropy from the auxiliary vector. VM supplies zeroed physical pages on demand, and the other half of the native arena remains available for independent mappings. libc rejects overflowing sizes and invalid alignments before invoking snmalloc. The allocator keeps its local state in TLS. Returning from a pthread start routine flushes and releases its local allocator. The QEMU test allocates in a worker, joins it, and frees the returned allocation from the primary thread.

Local login sessions

Local boot uses the FreeBSD /sbin/init port as a persistent PID 1. Init starts /usr/libexec/getty on the RISC-V firmware console, waits for the login chain, and reaps children. Getty starts /usr/bin/login. When the authenticated shell exits, the chain unwinds and init starts a new prompt. The session’s /usr/bin/help lists common shell builtins, base utilities, and administrative commands. Its /usr/bin/hello writes to standard output and can run in a pipeline. The FreeBSD shell uses # for an effective UID of zero and $ for other users.

The supervisor transfers sole access to serial input down this chain. Processes in the active console session write through the process service. When getty exits, the supervisor revokes the session’s console access and stops its remaining processes. The login program supplies local line editing and echo control.

Getty starts a new session and the login shell starts its own process group in that session. Spawned commands inherit both IDs. Native processes can query these IDs, join an existing group in their session, or become group or session leaders. A parent cannot use setpgid() to change the group of a child which has already started its program. waitpid() can select children by group, and kill() can address a group while checking permission for each member. The process service permits unprivileged signals within a native session when the sender and target IDs match. Bootstrapping retains its parent-child signal policy.

The serial console tracks a foreground process group in the active session. tcgetpgrp(), tcgetsid(), and tcsetpgrp() query this state and transfer foreground input to an existing group. The login shell’s group can restore foreground access when a job finishes. A read from a background group normally stops that group with SIGTTIN and retries when its members resume. A caller that ignores or blocks SIGTTIN, or belongs to an orphaned group, receives EIO. A foreground transfer cancels pending reads from the old group. Signal-driven job stops and starts are available through SIGSTOP and SIGCONT. The kernel parks the task’s threads at the boundary before their next userspace instruction and preserves outstanding IPC state. A waiting parent can collect the two transitions with WUNTRACED and WCONTINUED.

getrusage() reports user and supervisor CPU time for the caller or for its reaped children. The kernel measures scheduled thread time and the portion spent executing user contexts. The process service carries that accounting across an executable replacement and adds a child’s counters when its exit status is collected. Other usage counters are reserved. umask() updates the process’s inherited creation mask. The runtime uses FreeBSD’s setmode() and getmode() parser to apply symbolic permissions. The native root remains read-only.

The process service owns signal dispositions, pending signals, and the process mask. sigaction() can set a default action, ignore a signal, or register a one-argument handler. sigsuspend() changes the mask and defers its reply in the same operation. Delivery installs the handler’s mask and restores the earlier mask on return. A forked process inherits dispositions and the mask. execve() resets caught actions and preserves ignored actions. The service sends SIGCHLD after publishing child exits and terminal job stops to waiting parents. The initial runtime delivers caught signals on the primary thread.

RISC-V enters the runtime trampoline through a task-capability-checked kernel upcall. The kernel copies the interrupted user registers and PC to mapped stack memory before entering userspace. It can interrupt a blocked endpoint call and reports that interruption separately from channel closure. libc defers upcalls inside shared-buffer critical sections. The trampoline’s retained .eh_frame marks a signal frame and describes the interrupted PC and stack pointer.

The process service owns the active serial terminal’s attributes. tcgetattr() and tcsetattr() address it through a console descriptor. The foreground group can select canonical input, carriage-return translation, echo, and configurable erase, kill, and EOF characters. Canonical reads release a completed line or an EOF indication. The line buffer reserves enough space for the terminating newline. Raw input is the default for the bootstrap shell and login prompt, with single-byte reads and no timeout. The serial service drops line state and restores its default modes when the getty session ends. When ISIG is set, the service polls the serial input while a foreground job runs. The interrupt, quit, and suspend characters drop the current input line and send SIGINT, SIGQUIT, or SIGTSTP to the foreground process group. A waiting parent sees the stop through waitpid() and can restore the tty to its group before resuming the job.

Libc’s RISC-V LP64 nonlocal jump routines save the callee-saved integer registers, stack pointer, and return PC. The signal variants can also preserve the native signal mask. The hand-written assembly emits .eh_frame unwind information for its temporary frames and marks the nonlocal restore as an unwind boundary.

Native fork() creates a child with the caller’s saved register state, private mappings, working directory, and descriptor references. It inherits descriptors marked close-on-exec and skips descriptors marked close-on-fork. The supervisor issues fresh capabilities for the child’s process, file, and VM operations. VM keeps its own copy of the child’s mapping metadata, including pages which have yet to fault in. The current clone eagerly copies resident pages and returns EAGAIN if the source has worker threads or the system cannot allocate the child.

execve() and execv() use the native ELF loader and the same executable path policy as posix_spawn(). VFS resolves relative paths against the caller’s current working directory, checks search permission while traversing . and .., and applies execution policy to the resolved path. When the policy excludes a path, VFS checks its metadata using the caller’s credentials. Lookup reports ENOENT for a missing entry in a searchable directory. An existing file excluded by policy reports EACCES. For example, cd /bin; ./echo hello runs the installed executable. FreeBSD sh provides exec as a builtin, invoked as exec command. The replacement keeps the PID, parent, credentials, group, session, and VFS working directory. Before retiring the old task the supervisor validates the image, constructs its initial stack, and reserves its worker stack. It closes the close-on-exec descriptors, rebinds the private VM client, and then starts the replacement. On an image lookup or preparation failure the old task and its descriptors remain available. Loss of a trusted service during the final handoff is a fatal boot-runtime error.

pipe() and pipe2() allocate a pair of FIFO descriptors in VFS. The read and write ends enforce direction independently. The pipe preserves writes of up to 512 bytes atomically, and a blocked write wakes when its complete record fits. Readers drain queued bytes before observing EOF. A write after the last read end closes generates SIGPIPE and returns EPIPE if the signal is blocked.

VFS binds the console’s input and output to the initial standard file descriptors. Those descriptors have the usual close, duplicate, and inheritance semantics, including when a pipe replaces one of them. Libc routes console I/O to the process service after VFS confirms the descriptor refers to the console. That avoids calling the process service from inside VFS while the supervisor is waiting on VFS. F_GETFL reports the access mode and shared status of the open file description. F_SETFL can change nonblocking mode on pipes and sockets. Duplicate descriptors observe the same setting. Effective access checks use the filesystem’s writable status along with the inode’s mode and the caller’s credentials.

The boot adapter supplies an optional UTC timestamp from the firmware clock. The kernel pairs it with the monotonic counter at entry and passes both values through the boot information and native auxiliary vector. clock_gettime(CLOCK_REALTIME) and time() advance that sample using elapsed ticks. The initial accuracy is limited by the firmware’s whole-second sample. The clock has no adjustment interface and reports ENOTSUP when the boot adapter has no timestamp.

nanosleep() waits on a temporary native event queue with a monotonic timeout. Signals interrupt the timed IPC wait and return EINTR. Libc computes the remaining interval from the monotonic clock when the caller requests it. A zero interval completes without a queue.

flock() applies shared or exclusive advisory locks to open file descriptions. Independent opens of the same inode check the same lock set. Duplicate and inherited descriptors share the lock until an explicit unlock or the last close. A conflicting nonblocking request returns EWOULDBLOCK. Blocking callers sleep through VFS, and a blocking upgrade releases its shared lock before waiting.

The fcntl() record locks use mount, inode, process, and byte range as their identity. Closing a descriptor drops that process’s locks on the file. A forked child has independent lock ownership. F_SETLK reports a conflict immediately, and F_GETLK identifies a conflicting lock. F_SETLKW waits on a deferred VFS reply with its range fixed at the original request. VFS publishes a grant only after delivering the reply, so an interrupted wait leaves no lock behind. It reports EDEADLK when a new wait would complete a cycle through processes holding conflicting locks.

The native root image builder installs /etc/group and derives the seven-field public /etc/passwd from the ten-field /etc/master.passwd. The public file always contains * in the password field. The master file is owned by UID and GID 0 with mode 0600. The builder gives each configured home directory its account’s UID and primary GID and mode 0700. The built-in development accounts use their usernames as passwords and store salted SHA512-crypt verifiers. Set SYSTEM_MASTER_PASSWD and SYSTEM_GROUP while building the image to supply local account records. The builder checks the account IDs, group membership, home paths, login shells, and verifier format.

Libc looks up public user and group records by name or numeric ID. The reentrant lookup functions return results in caller-owned storage, return ERANGE when it is too small, and report a missing record with a null result. These functions do not open the protected master file.

The process service stores up to 16 supplementary GIDs per process. getgroups() reads the current list, and setgroups() replaces it atomically for callers with effective UID 0. A child inherits its parent’s list. The supervisor publishes effective credentials and the list together in a page mapped read-only into VFS. The root filesystem applies owner permissions first, then group permissions if the effective GID or a supplementary GID matches, and finally other permissions.

The password verifier uses the pinned FreeBSD SHA512-crypt implementation. It accepts a $6$ verifier with a salt of up to 16 characters and the standard 5000 rounds. Password inputs are limited to 127 bytes. The verifier compares the complete digest and clears the temporary digest. The guest regression checks an upstream known answer and rejects incorrect passwords and malformed records.

Login reads the password with echo disabled and looks up its verifier in the protected master file. On success it records the authenticated name in the console session, sets the primary and supplementary groups, permanently drops privileges for a non-root login, changes to the account’s home directory, and enables canonical serial input and job signals before launching FreeBSD /bin/sh. getlogin() reads the session name independently of the command’s environment. The login process alone can set that name, and getty teardown clears it. The login shell receives a fresh environment. Account administration on writable ext4 uses pw and pwd_mkdb. The latter validates a master file and derives the public password file from it. Both commands publish the master, public password, and group files together. A root-only advisory lock serializes writers. The writer stages and flushes the new files before creating a durable marker, replaces the canonical files, advances a generation number, and clears the marker after flushing the directory. Libc and login validate the generation before and after reading records. The lookup functions return EAGAIN if publication crosses their read. Init replays a marked update before opening the console. An unrelated open descriptor on a replacement target may delay publication on the bootstrap ext4 backend. The writer reports that error and retains the marker for replay.

pw supports local user and group records, supplementary groups, SHA512-crypt verifiers, lock and unlock, and creation of owned home directories. adduser creates a locked local account by default and can forward account options to pw. rmuser removes account records and group memberships, and attempts to remove an empty home owned by the account. Its confirmation can be skipped with -y.

ttyname() and ttyname_r() identify the emulated serial console as /dev/console. The console terminal attributes cover canonical input, echo, signal generation, and six configurable control characters. stty can report or restore these attributes. Terminal speed and line disciplines belong to the device implementation.

The native uname() interface reports the System release and the compiler target’s native architecture name. It uses the root’s configured hostname. execvp() searches the caller’s PATH and tries the native shell on executable text that returns ENOEXEC.

An ordinary native process can spawn an executable directly inside /bin, /sbin, /usr/bin, or /usr/sbin, subject to the filesystem’s execute and directory search permissions. The supervisor starts /sbin/init separately. The /sbin/shutdown -p now and /sbin/reboot commands ask the process service to use its kernel power capability. The process service authorizes effective UID 0, and the kernel invokes the platform reset interface. The commands return an error when denied or when the firmware reports failure.

The native image builds FreeBSD sh from revision 4ba6fd2ef5a7. The build runs the upstream generators for the builtin, syntax, node, and token tables with the host tools. The shell uses fork(), execve(), descriptor redirection, pipes, and native process groups. The console supports the shell’s jobs, bg, and fg builtins. Line editing through libedit, verified script execution, timed read, and resource limit configuration depend on further native support. The printf builtin initially supports byte strings and integer conversions. The times builtin formats the process service’s CPU counters in milliseconds.

The initial FreeBSD base commands include /bin/echo, /bin/pwd, /bin/kill, /usr/bin/true, /usr/bin/false, /usr/bin/id and its groups and whoami entry points, and /usr/sbin/nologin. id uses the native group database and process credentials for UID, GID, supplementary group, home, and shell queries. nologin records denial through the native serial LOG_CONS fallback and exits with failure. The fallback writes to the firmware serial stream. The FreeBSD audit, MAC label, and login-class options require their corresponding services.