platform

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package platform contains the small amount of process behaviour that is inherently operating-system specific. Keeping it outside the session package makes the PTY lifecycle compile cleanly on unsupported platforms.

Index

Constants

This section is empty.

Variables

View Source
var ErrShellUnsupported = errors.New("shell execution not supported on this platform")

ErrShellUnsupported reports that the current platform has no supported system shell launcher for PTY-backed sessions.

View Source
var ReplaceTimeout = 2 * time.Second

ReplaceTimeout bounds how long a replacement waits for a refusal to clear. It is a var so a test can shorten it; nothing else should write it.

Functions

func IsPTYCloseError

func IsPTYCloseError(err error) bool

IsPTYCloseError recognizes the EIO returned by many Unix PTY masters after the slave side has closed.

func KillProcessGroup

func KillProcessGroup(command *exec.Cmd)

KillProcessGroup forcefully stops the process group and then kills the leader as a fallback in case group signalling failed.

func NewShellCommand

func NewShellCommand(ctx context.Context, script string) (*exec.Cmd, error)

NewShellCommand constructs the explicitly requested Unix shell invocation. The script is passed as one argument; it is never interpolated by Relayer.

func ProcessGroupExists

func ProcessGroupExists(command *exec.Cmd) bool

ProcessGroupExists reports whether the command's process group still exists.

func PublishByRename added in v0.8.1

func PublishByRename(source, target string) error

PublishByRename moves a fully written temporary file over the file it replaces, waiting out a transient platform refusal.

A failure that will not clear -- a missing source, a missing directory -- is returned at once: waiting does not create a file, and the caller needs the report now.

func RemoveFile added in v0.8.1

func RemoveFile(path string) error

RemoveFile deletes a file, waiting out a transient platform refusal.

A file that is already absent is not an error: callers use this to clear a path before writing it, and a path that is already clear is the state they wanted.

func RetryWhileTransient added in v0.8.1

func RetryWhileTransient(operation func() error) error

RetryWhileTransient runs an operation until it succeeds, fails permanently, or the budget is spent. The last error is returned unwrapped so a caller can still inspect it.

func TerminateProcessGroup

func TerminateProcessGroup(command *exec.Cmd)

TerminateProcessGroup asks the whole process group led by command to stop. creack/pty starts commands in a new session on Unix, so the command PID is also the process-group ID.

func TransientFileError added in v0.8.1

func TransientFileError(error) bool

TransientFileError reports nothing as transient away from Windows.

rename(2) and unlink(2) do not fail because another process holds the file open, so every error they return is a real one: a missing path, a cross-device move, a permission problem. Retrying would delay the report without changing it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL