From 043768076fda6a15834a3a248181a6d20953a3e3 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 27 Jul 2022 17:03:55 -0700 Subject: [PATCH] Explain pty Process abstraction (#3254) Signed-off-by: Spike Curtis --- pty/pty.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pty/pty.go b/pty/pty.go index a5e7adc145..7db4a88884 100644 --- a/pty/pty.go +++ b/pty/pty.go @@ -29,7 +29,11 @@ type PTY interface { Resize(height uint16, width uint16) error } -// Process represents a process running in a PTY +// Process represents a process running in a PTY. We need to trigger special processing on the PTY +// on process completion, meaning that we will have goroutines calling Wait() on the process. Since +// the caller will also typically wait for the process, and it is not safe for multiple goroutines +// to Wait() on a process, this abstraction provides a goroutine-safe interface for interacting with +// the process. type Process interface { // Wait for the command to complete. Returned error is as for exec.Cmd.Wait()