Skip to content

UnixInstance

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

A live, booted system — the handle returned by a runtime’s boot().

Consumed — obtain one from UnixBuilder.boot(runtime) or runtime.boot(image). Not an interface user code implements.

A UnixInstance is a single running system. boot() starts the shell as PID 1 and resolves when it exits; shutdown() performs an orderly teardown (SIGTERM to all → grace period → SIGKILL). The kernel reference is primarily for inspection and tests — bins should go through ProcContext.

[Symbol.asyncDispose] is implemented so you can use await using — this calls shutdown(), so DO NOT put the instance into a long-lived scope bound to using unless you actually want teardown on scope exit.

import { Unix, stdSystem } from '@fishnet/core'
import { nodeRuntime } from '@fishnet/runtime'
await using sys = await Unix().use(stdSystem()).boot(nodeRuntime())
const code = await sys.wait()

readonly kernel: Kernel

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

Access kernel for inspection/testing.

[asyncDispose](): Promise<void>

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

Async disposable — delegates to shutdown().

Promise<void>


boot(): Promise<ExitCode>

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

Boot a shell as PID 1. Resolves with the shell’s exit code.

Promise<ExitCode>

The kernel keeps running after the shell exits (services may outlive it); call shutdown() to tear everything down


shutdown(): Promise<void>

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

Gracefully shut down the system.

Promise<void>

SIGTERM → configured grace period → SIGKILL; resolves only after all processes are reaped


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

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

Spawn any bin as a top-level process (ppid=0).

string | BinFunction

string[]

SpawnOpts

Promise<ChildHandle>

Runs independently of the shell; the bin’s exit does NOT shut down the instance — call shutdown() explicitly


wait(): Promise<ExitCode>

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

Wait for the system to shut down (shell exit).

Promise<ExitCode>