Start begins execution of the command
()
| 58 | |
| 59 | // Start begins execution of the command |
| 60 | func (s *SSHProcessController) Start() error { |
| 61 | s.lock.Lock() |
| 62 | defer s.lock.Unlock() |
| 63 | |
| 64 | if s.started { |
| 65 | return fmt.Errorf("command already started") |
| 66 | } |
| 67 | |
| 68 | fullCmd, err := BuildShellCommand(s.cmdSpec) |
| 69 | if err != nil { |
| 70 | return fmt.Errorf("failed to build shell command: %w", err) |
| 71 | } |
| 72 | // if stdout/stderr weren't piped, then session.stdout/stderr will be nil |
| 73 | // and the library guarantees that the outputs will be attached to io.Discard |
| 74 | // if stdin hasn't been piped, then session.stdin will be nil |
| 75 | // and the libary guarantees that it will be attached to an empty bytes.Buffer, which will produce an immediate EOF |
| 76 | // tl;dr we don't need to worry about hanging beause of long input or explicitly closing stdin |
| 77 | if err := s.session.Start(fullCmd); err != nil { |
| 78 | return fmt.Errorf("failed to start command: %w", err) |
| 79 | } |
| 80 | s.started = true |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | // Wait waits for the command to complete |
| 85 | func (s *SSHProcessController) Wait() error { |
nothing calls this directly
no test coverage detected