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 ¶
- Variables
- func IsPTYCloseError(err error) bool
- func KillProcessGroup(command *exec.Cmd)
- func NewShellCommand(ctx context.Context, script string) (*exec.Cmd, error)
- func ProcessGroupExists(command *exec.Cmd) bool
- func PublishByRename(source, target string) error
- func RemoveFile(path string) error
- func RetryWhileTransient(operation func() error) error
- func TerminateProcessGroup(command *exec.Cmd)
- func TransientFileError(error) bool
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
IsPTYCloseError recognizes the EIO returned by many Unix PTY masters after the slave side has closed.
func KillProcessGroup ¶
KillProcessGroup forcefully stops the process group and then kills the leader as a fallback in case group signalling failed.
func NewShellCommand ¶
NewShellCommand constructs the explicitly requested Unix shell invocation. The script is passed as one argument; it is never interpolated by Relayer.
func ProcessGroupExists ¶
ProcessGroupExists reports whether the command's process group still exists.
func PublishByRename ¶ added in v0.8.1
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
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
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 ¶
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
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.