Documentation
¶
Overview ¶
Package session owns direct PTY process lifecycle and timed raw/input events.
See internal/pty/doc.go for the governing ADR/SPIKE citations that authorize this package boundary.
Index ¶
- Variables
- func KeyBytes(k Key) ([]byte, error)
- type Clock
- type Config
- type Event
- type EventKind
- type ExitStatus
- type Key
- type Option
- type OutputChunk
- type Session
- func (s *Session) Close() error
- func (s *Session) Events() <-chan Event
- func (s *Session) Kill() error
- func (s *Session) Output() <-chan OutputChunk
- func (s *Session) Resize(size Size) error
- func (s *Session) SendBytes(b []byte) error
- func (s *Session) SendKey(k Key) error
- func (s *Session) Size() Size
- func (s *Session) Wait() ExitStatus
- type Size
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed is returned when writing to a closed session. ErrClosed = errors.New("pty session closed") )
Functions ¶
Types ¶
type Event ¶
type Event struct {
Seq uint64
Kind EventKind
At time.Time
TMS int64
Offset int64
Bytes []byte
Key Key
Size Size
Signal string
Exit *ExitStatus
Err error
}
Event is the narrow timed event shape consumed by follow-on cassette code.
type ExitStatus ¶
ExitStatus describes process termination.
type Option ¶
type Option func(*Config)
Option configures Start.
func WithBufferSize ¶
WithBufferSize changes the raw read buffer size.
func WithTimeout ¶
WithTimeout applies a wall-clock timeout in addition to ctx cancellation.
type OutputChunk ¶
type OutputChunk struct {
Seq uint64
At time.Time
TMS int64
Offset int64
Bytes []byte
ReadError error
EOF bool
}
OutputChunk is one timed raw PTY read.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a running PTY-backed process.
func Start ¶
func Start(ctx context.Context, command string, args []string, workdir string, env []string, size Size, opts ...Option) (*Session, error)
Start launches command under a direct PTY with argv, workdir, env, and size. Cancellation is controlled by ctx and WithTimeout.
func (*Session) Kill ¶
Kill terminates the process group where supported and records a signal event. If the process exits naturally at the same time, the signal event is best effort and may race with the exit event.
func (*Session) Output ¶
func (s *Session) Output() <-chan OutputChunk
Output returns timed raw PTY chunks. The channel closes after the read loop reaches EOF or Close/Kill tears the PTY down.
func (*Session) SendKey ¶
SendKey writes a named key sequence to the PTY and records an input event.
func (*Session) Wait ¶
func (s *Session) Wait() ExitStatus
Wait blocks until the process exits and returns its exit status.