ScriptPtyShellSession class

A ShellSession backed by a real pseudo-terminal allocated by the system script(1) utility, which runs as an ordinary child Process.

Unlike the FFI-based PtyShellSession (which loads the portable_pty native library), all PTY ownership — forkpty, the controlling terminal and signal handling — lives inside the script process. The node only does pipe I/O and reaps a normal child, so this backend cannot trigger the native SIGCHLD crash that affects portable_pty.

script bridges the child's tty to its own stdin/stdout, so:

  • stdout is the merged terminal output (the pty folds stderr into stdout);
  • writeStdin feeds the child's tty input;
  • exitCode is the child's exit status, surfaced by script.

script launched from pipes leaves the node no pty fd of its own, so resize can't follow a SIGWINCH the usual way. Instead the backend has the wrapper record the child's controlling-tty path (tty → _ttyFile) at spawn, and resize sets the window size directly on that PTS with stty — which fires TIOCSWINSZ, so the kernel delivers SIGWINCH to the foreground program and it reflows. No FFI, no native library. The initial geometry is still seeded via stty rows/cols before exec.

Implemented types

Constructors

ScriptPtyShellSession(Process _process, {String? ttyFile, Directory? ttyDir})
Wraps an already-started script Process. ttyFile (and its owning ttyDir) carry the child PTS path for resize.

Properties

exitCode → Future<int>
Completes with the process exit code once it terminates.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
pid → int?
The backend process id, if known.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shellFamily → ShellFamily
The command-language family of the launched shell, so the client can speak the matching marker/command dialect over an interactive session.
no setteroverride
stderr → Stream<Uint8List>
Bytes written by the process to standard error.
no setteroverride
stdout → Stream<Uint8List>
Bytes written by the process to standard output.
no setteroverride

Methods

closeStdin() → Future<void>
Signals end-of-input on standard input (half-close).
override
kill() → Future<void>
Forcibly terminates the process and releases resources.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resize({required int cols, required int rows}) → void
Resizes the terminal, where the backend supports it (no-op otherwise).
override
sendSignal(String signal) → void
Sends a POSIX signal name (e.g. SIGINT, SIGTERM) to the process.
override
toString() → String
A string representation of this object.
inherited
writeStdin(List<int> data) → void
Writes data to the process's standard input.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited