# tmuxtest.PTYProcess

- **Module:** tmuxtest
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/tmuxtest/pty_process.go#L19
- **Page:** https://libtmux.org/en/go/latest/reference/tmuxtest-ptyprocess/

PTYProcess is a test subprocess that owns an isolated controlling terminal and a memory-backed transcript. It comes from [StartPTYProcess]. Output may be read concurrently through [PTYProcess.Output]; writes are serialized.

## Members

- `Done` (method): Done is closed when the subprocess exits. It can close before the terminal reader has added the final bytes to [PTYProcess.Output].
- `Write` (method): Write sends terminal input to the subprocess within ctx. Writes are serialized and can be partial. A waiting caller may cancel before acquiring the writer, and an active write observes ctx cancellation.
- `Wait` (method): Wait waits for process completion and the final output drain, or ctx cancellation. A successful Wait guarantees that [PTYProcess.Output] contains the completed transcript.
- `Output` (method): Output returns a fresh copy of terminal output collected so far. A successful [PTYProcess.Wait] guarantees that the returned transcript includes the final drain.
- `Close` (method): Close stops the subprocess if needed and releases the PTY master. It is safe to call concurrently and more than once.
- `CloseContext` (method): CloseContext starts an idempotent shutdown and waits within ctx. Concurrent calls join the same shutdown. If ctx ends after shutdown starts, shutdown continues and a later call may wait for completion; an already-ended ctx does not start shutdown.
