createConsFS
createConsFS(
tty,opts):ConsResult
Defined in: packages/core/src/kernel/tty/cons.ts:293
Create a consolidated tty fileserver (data/ctl/size) bound to a TtyConfig.
Parameters
Section titled “Parameters”TTY device configuration (backing ttyFS settings).
Size polling callback + optional signal hook; see ConsOpts.
Returns
Section titled “Returns”A ConsResult pairing the mountable fileserver with the host-side terminal handle.
Remarks
Section titled “Remarks”Plan 9’s unified /dev/cons replaces the older ttyFS + ldisc +
ttyCtlFS trio with a single directory whose three inner nodes own the
whole terminal protocol:
data— byte stream; reads go through the line discipline’s cooked or raw mode, writes pass through to the host stdout.ctl— writable commandsrawon/rawoff(toggle ldisc mode) andsetfg <pgid>(set foreground process group for signal delivery). Reads return a one-shot status line then EOF.size— reads return${cols} ${rows}\n(polls ConsOpts.getTermSize each time).
The returned ConsResult.terminal is the host-side I/O handle; the
ConsResult.server mounts at /dev/cons. mkdir, remove,
rename, wstat all throw EPERM. Post-dispose(), every fileserver
method throws EIO.
Example
Section titled “Example”import { createConsFS, Unix } from '@fishnet/core'const { server, terminal } = createConsFS(ttyConfig, { getTermSize: () => ({ cols: process.stdout.columns, rows: process.stdout.rows }), onSignal: (sig, fgPgid) => kernel.signalGroup(fgPgid, sig),})const sys = await Unix().mount('/dev/cons', server).build().boot()// host-side: pipe process.stdin → terminal.stdin, terminal.stdout → process.stdoutCaveat
Section titled “Caveat”Single-owner: the returned ConsTerminal assumes exclusive host-side control. Multiplexing one consFS across two host adapters is not supported.