Skip to content

ProcContext

Defined in: packages/core/src/kernel/types.ts:456

The system call interface available to every bin. Every running process receives a ProcContext.

ProcContext is the single API surface bins use to interact with the system. It provides process identity, I/O streams, filesystem access via ProcFS, process lifecycle control (spawn, exec, exit, signal, wait), namespace manipulation, and optional capabilities (catalog install, service registration, srv posting).

Optional members (catalogInstall?, registerExec?, registerService?, etc.) are present only when the system was built with the corresponding capability. Bins must check for their existence before calling.

const myBin: BinFunction = async (proc) => {
const name = proc.argv[1] ?? 'world'
await proc.stdout.write(`Hello, ${name}!\n`)
const content = await proc.fs.readFile('/etc/motd')
await proc.stderr.write(content)
return exitCode(0)
}

readonly abortSignal: AbortSignal

Defined in: packages/core/src/kernel/types.ts:478

Abort signal — aborted when the process is killed. Bins can check abortSignal.aborted or pass it to fetch/AbortController-aware APIs.


readonly argv: string[]

Defined in: packages/core/src/kernel/types.ts:463

Command-line arguments. argv[0] is the command name.


optional catalogInstall?: (name) => Promise<CatalogInstallResult | undefined>

Defined in: packages/core/src/kernel/types.ts:521

Install a package from the pre-bundled catalog. Present only when the system was built with .catalog() entries. Returns install info or undefined if the package is not in the catalog.

string

Promise<CatalogInstallResult | undefined>


readonly cwd: AbsPath

Defined in: packages/core/src/kernel/types.ts:467

Current working directory (absolute path).


env: Record<string, string>

Defined in: packages/core/src/kernel/types.ts:465

Environment variables. Mutable — changes are visible to child processes.


readonly fs: ProcFS

Defined in: packages/core/src/kernel/types.ts:481

Filesystem operations routed through this process’s namespace.


optional getServer?: (name) => Fileserver | undefined

Defined in: packages/core/src/kernel/types.ts:548

Retrieve a posted Fileserver from /srv by name.

string

Fileserver | undefined


readonly pid: Pid

Defined in: packages/core/src/kernel/types.ts:458

Process identifier for this process.


optional postServer?: (name, server) => void

Defined in: packages/core/src/kernel/types.ts:545

Post a Fileserver to /srv for other processes to discover and mount.

string

Fileserver

void


readonly ppid: Pid

Defined in: packages/core/src/kernel/types.ts:460

Parent process identifier (0 = kernel-spawned).


optional registerExec?: (binName, fn) => void

Defined in: packages/core/src/kernel/types.ts:527

Register a bin function on the filesystem exec table. Present when the system supports runtime package installation.

string

BinFunction

void


optional registerService?: (def) => Promise<void>

Defined in: packages/core/src/kernel/types.ts:535

Register and start a service at runtime (post-boot). Present when init is running with a supervisor. Validates bin is resolvable before registering. Services go through existing supervisor machinery (restart policies, backoff).

ServiceDef

Promise<void>


optional removeServer?: (name) => void

Defined in: packages/core/src/kernel/types.ts:551

Remove a posted Fileserver from /srv.

string

void


optional resolveBin?: (name) => Promise<BinFunction | undefined>

Defined in: packages/core/src/kernel/types.ts:542

Resolve a bin name to a BinFunction via the kernel’s exec resolution (namespace/ExecCapable/$PATH lookup). Used by the shell to discover promoted builtins (e.g. pkg) at runtime without a static import.

string

Promise<BinFunction | undefined>


optional shellOpts?: ShellOpts

Defined in: packages/core/src/kernel/types.ts:566

Shell option flags (e.g. xtrace). Present when the process is running inside a shell interpreter; undefined in non-shell contexts.


readonly stderr: Writable

Defined in: packages/core/src/kernel/types.ts:474

Standard error stream.


readonly stdin: Readable

Defined in: packages/core/src/kernel/types.ts:470

Standard input stream.


readonly stdout: Writable

Defined in: packages/core/src/kernel/types.ts:472

Standard output stream.

bind(oldPath, newPath, flags?): void

Defined in: packages/core/src/kernel/types.ts:510

string

string

BindFlags

void


chdir(path): Promise<void>

Defined in: packages/core/src/kernel/types.ts:506

string

Promise<void>


exec(bin, argv): never

Defined in: packages/core/src/kernel/types.ts:497

Replace the current process image with a new bin. Throws an ExecSentinel that the kernel catches — code after exec() never runs. Same pid, same fds, same namespace. Used by login → shell transition.

string | BinFunction

string[]

never


exit(code?): never

Defined in: packages/core/src/kernel/types.ts:498

ExitCode

never


optional getTermSize(): TerminalSize

Defined in: packages/core/src/kernel/types.ts:560

Return current terminal dimensions, if a controlling terminal exists.

TerminalSize


mount(server, path): void

Defined in: packages/core/src/kernel/types.ts:509

Fileserver

string

void


off(signal): void

Defined in: packages/core/src/kernel/types.ts:514

Signal

void


on(signal, handler): void

Defined in: packages/core/src/kernel/types.ts:513

Signal

() => void

void


resolveServer(path): Fileserver | undefined

Defined in: packages/core/src/kernel/types.ts:554

Resolve a path to the Fileserver mounted at that point (for post/srv).

string

Fileserver | undefined


setsid(): Pid

Defined in: packages/core/src/kernel/types.ts:505

Pid


setuid(uid): void

Defined in: packages/core/src/kernel/types.ts:504

Uid

void


signal(pid, sig): void

Defined in: packages/core/src/kernel/types.ts:499

Pid

Signal

void


spawn(bin, argv, opts?): Promise<ChildHandle>

Defined in: packages/core/src/kernel/types.ts:491

Spawn a child process.

string | BinFunction

A BinFunction or a string path resolved via $PATH.

string[]

Arguments for the child. argv[0] is conventionally the command name.

SpawnOpts

Optional I/O redirects, env overrides, cwd.

Promise<ChildHandle>

A ChildHandle with the child’s pid and I/O streams.


unmount(path): void

Defined in: packages/core/src/kernel/types.ts:557

Remove a mount point from this process’s namespace.

string

void


wait(pid): Promise<ExitCode>

Defined in: packages/core/src/kernel/types.ts:500

Pid

Promise<ExitCode>


waitAny(): Promise<{ code: ExitCode; pid: Pid; }>

Defined in: packages/core/src/kernel/types.ts:501

Promise<{ code: ExitCode; pid: Pid; }>