Skip to content

procFS

procFS(table, opts?): Fileserver

Defined in: packages/core/src/kernel/fileservers/proc.ts:472

Create a /proc fileserver backed by the kernel process table.

Map<Pid, Process>

Live process table the kernel mutates. The fileserver holds this map by reference — entries added/removed by the kernel become visible on the next /proc readdir.

ProcFSOpts

Optional callbacks that gate individual virtual files; see ProcFSOpts.

Fileserver

A read-mostly Fileserver projecting the process table.

Mount at /proc to expose a live view of the process table as a Plan-9-style synthetic tree:

  • /proc/<pid>/status — formatted pid/ppid/state/uid/cwd.
  • /proc/<pid>/env, /argv, /cwd, /fd — scalar projections.
  • /proc/<pid>/ctl — writable control file (present iff opts.signal supplied).
  • /proc/<pid>/ns — namespace mount list (present iff opts.getNs supplied).
  • /proc/log — kernel log snapshot (present iff opts.log supplied).

Reads are snapshot-at-open: a reader holding a long-lived fd observes the state captured when open() was called. To re-read fresh state, close and re-open.

All writes to non-ctl paths throw EACCES; all mkdir / remove / rename / wstat operations throw EPERM.

import { procFS } from '@fishnet/core'
const fs = procFS(kernel.processTable, {
log: kernel.log,
signal: (pid, sig) => kernel.signal(pid, sig),
getNs: (pid) => formatNamespace(kernel.processTable.get(pid)),
})

The signal / getNs / getSuspended callbacks typically close over a kernel reference that is only initialized after procFS returns (see createContainerKernel). Wire them with a mutable let kernel forward-reference if you compose this factory yourself.