screenReconnectingPTY provides a reconnectable PTY via `screen`.
| 25 | |
| 26 | // screenReconnectingPTY provides a reconnectable PTY via `screen`. |
| 27 | type screenReconnectingPTY struct { |
| 28 | logger slog.Logger |
| 29 | execer agentexec.Execer |
| 30 | command *pty.Cmd |
| 31 | |
| 32 | // id holds the id of the session for both creating and attaching. This will |
| 33 | // be generated uniquely for each session because without control of the |
| 34 | // screen daemon we do not have its PID and without the PID screen will do |
| 35 | // partial matching. Enforcing a unique ID should guarantee we match on the |
| 36 | // right session. |
| 37 | id string |
| 38 | |
| 39 | // mutex prevents concurrent attaches to the session. Screen will happily |
| 40 | // spawn two separate sessions with the same name if multiple attaches happen |
| 41 | // in a close enough interval. We are not able to control the screen daemon |
| 42 | // ourselves to prevent this because the daemon will spawn with a hardcoded |
| 43 | // 24x80 size which results in confusing padding above the prompt once the |
| 44 | // attach comes in and resizes. |
| 45 | mutex sync.Mutex |
| 46 | |
| 47 | configFile string |
| 48 | |
| 49 | metrics *prometheus.CounterVec |
| 50 | |
| 51 | state *ptyState |
| 52 | // timer will close the reconnecting pty when it expires. The timer will be |
| 53 | // reset as long as there are active connections. |
| 54 | timer *time.Timer |
| 55 | timeout time.Duration |
| 56 | } |
| 57 | |
| 58 | // newScreen creates a new screen-backed reconnecting PTY. It writes config |
| 59 | // settings and creates the socket directory. If we could, we would want to |
nothing calls this directly
no outgoing calls
no test coverage detected