Commit c47bd0a
committed
🤖 Fix SSH exec timeout with ControlMaster socket reuse
## Problem
SSH commands with timeout could run indefinitely on remote hosts despite
client-side timeouts. When ControlMaster multiplexing was enabled, killing
the local SSH client didn't terminate the remote command—it continued
running under the shared master connection.
## Solution
**Three-layer timeout protection:**
1. **Client-side timeout** - SIGKILL after timeout expires (immediate local cleanup)
2. **Remote-side timeout** - Wrap commands with `timeout -s KILL` utility
3. **SSH connection timeout** - ConnectTimeout + ServerAlive* options
Remote timeout is set to `timeout + 1s` to ensure local timeout normally
fires first for cleaner error handling. Uses BusyBox-compatible syntax
(`-s KILL`) for Alpine Linux compatibility.
**ControlMaster always enabled** - Socket reuse now works for all operations,
including timed commands. This preserves 50-200ms performance savings per
operation from connection pooling.
## Testing
- Added timeout integration test for both local and SSH runtimes
- Verifies `sleep 10` with 1s timeout completes in ~1s (not 10s)
- All 88 integration tests pass
- 807 unit tests pass (4 pre-existing gitService failures unrelated)
## Impact
Commands with timeout now properly terminate on remote hosts while
maintaining the performance benefits of SSH connection multiplexing.1 parent 86323fa commit c47bd0a
2 files changed
+61
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
94 | 106 | | |
95 | 107 | | |
96 | | - | |
| 108 | + | |
97 | 109 | | |
98 | 110 | | |
99 | 111 | | |
| |||
117 | 129 | | |
118 | 130 | | |
119 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
120 | 138 | | |
121 | 139 | | |
122 | 140 | | |
123 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
124 | 158 | | |
125 | 159 | | |
126 | 160 | | |
| |||
167 | 201 | | |
168 | 202 | | |
169 | 203 | | |
170 | | - | |
| 204 | + | |
171 | 205 | | |
172 | 206 | | |
173 | 207 | | |
174 | 208 | | |
175 | 209 | | |
176 | 210 | | |
177 | | - | |
| 211 | + | |
178 | 212 | | |
179 | 213 | | |
180 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
145 | 168 | | |
146 | 169 | | |
147 | 170 | | |
| |||
0 commit comments