LibTmux.Program
Run terminal applications through an owned scope. Use
withProgram for an interactive handle or
runProgram for a final result. These operations borrow the
selected daemon and own only their new session, application process group,
native command clients, pin, buffers and files.
Source and package
- Qualified name
-
LibTmux. Program - Package
- libtmux-haskell
- Source
- src/LibTmux/Program.hs
- LibTmux.Program
-
Description
A scope sends TERM, waits up to 100ms for leader exit, then sends group KILL through a retained Linux pidfd. Completed cleanup proves leader exit and an empty retained process group. Zombies or uninterruptible members may leave a reachable cleanup recovery. Processes that move to another process group/session escape this contract. Linux 6.9 process-group pidfd signaling and a local daemon in the same PID and filesystem namespaces are required. The selected
bootstrapShellmust provide Bash dynamic descriptors, timed reads and execfail. It defaults to/bin/bashand is probed before application creation. The gate has a separate one-second startup lease;commandTimeoutbounds each native command. Neither bounds whole startup:executionTimeoutbounds owning setup and the callback. Cleanup wakes a blocked gate with an abort claim; the descriptor closes before application exec. The host operation and tmux 3.8 capability are checked before application resources are created.Output is a bounded rendered snapshot, not stdout/stderr byte streaming. Controller-process crash recovery, persistent leases, readiness predicates, keep/detach and MCP operations remain unimplemented. Use the scope while its callback runs; detached
ProgramResultvalues survive cleanup.
Members20 members
Common operations13
- inspectProgramCleanup function Inspect local ownership without contacting tmux or waiting.
- Program data type An interactive owner, valid only inside its withProgram callback. The
borrowed Server may close independently; incomplete cleanup retains its own
pin and Runtime through
ProgramRecovery. - programCleanupFailure function The failure from the cleanup attempt that attached this owner. The original callback exception remains the thrown exception.
- ProgramOptions data type A literal executable and its arguments. The record has no Show instance:
command and environment values may contain credentials. The working
directory defaults to the caller's directory; environment values override
the daemon's inherited application environment. Start from
programOptions. - programRecoveries function Retrieve owners from an exception caught with its exception context.
- ProgramRecovery data type Reachable cleanup ownership, including a live pin, native Runtime and identity-bound application group. Resume does not run the application again.
- ProgramResult data type Detached final output and process status, usable after all scopes close.
- readProgramScreen function Capture the current rendered terminal. Limits are configured before launch; the result reports clipped bytes and possible history loss explicitly. An external resize refuses capture before allocation; cleanup remains available.
- resumeProgramCleanup function Retry cleanup through its retained pin, including after the borrowing Server scope ends. Application launch and input are never repeated.
- sendProgramInput function Send literal bytes to the real application PTY. A call admits at most 1024 bytes, including NUL; terminal line discipline still applies. Sending bytes is not evidence that the application consumed them.
- terminateProgram function Request TERM, wait up to 100ms for leader exit, then send KILL to the retained process-group identity. Descendants that move to another group/session are outside this ownership contract. The returned outcome belongs to the leader.
- waitProgram function Observe the real process exit and tmux's final PTY drain. Cancelling this observation leaves the owning scope and application running. A destroyed pane or lost daemon raises an observation error instead of inventing an exit.
- waitProgramFor function Bound only this observation. Nothing means the deadline elapsed; it does not terminate the application. Async cancellation also leaves it running.
Other members7
- ProgramCleanupStatus data type Nonblocking cleanup metadata, without application arguments or output.
- ProgramError data type Program-specific failures. Existing native command failures also retain their ordinary correlated recovery. Async exceptions keep their class.
- ProgramExit data type The pane's actual process outcome. A signal is never encoded as 128+signal. Successful creation and bootstrap release do not establish successful exec.
- programOptions function Default terminal, bounded history and output, with a literal argv tail. An empty tail executes a zero-argument application without tmux shell mode.
- ProgramScreen data type A rendered terminal snapshot, including retained history. This is not a byte stream or a separation of stdout and stderr. Newlines and terminal editing follow capture-pane. Byte omission is exact for this snapshot; history omission is reported separately.
- StartFailure data type Setup failed before replacing the bootstrap with the requested executable.
- StartPhase data type Strict application setup, independent of tmux's cwd fallback.
No members of LibTmux.Program match . The filter searches only this type. Search the whole API.
Order: the accessors that walk the hierarchy, the operations the ports share, then the rest.
Referenced by
references 2Declarations that take LibTmux.Program as a pointer or callback: a reference, not a call.
- LibTmux module
- LibTmux.Recovery module
Guides
task materialPages that discuss LibTmux.Program.