File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 88 "strings"
99 "sync"
1010 "syscall"
11+ "unicode"
1112
1213 "github.com/fsnotify/fsnotify"
1314 "github.com/snorwin/haproxy-reload-wrapper/pkg/exec"
@@ -183,14 +184,27 @@ func runInstance() {
183184 cmds = append (cmds , cmd )
184185}
185186
187+ // pids returns the PID list as a space-separated string
186188func pids () string {
187189 if len (cmds ) == 0 {
188190 return ""
189191 }
190192
191193 out := make ([]string , 0 , len (cmds ))
192194 for _ , c := range cmds {
193- out = append (out , strconv .Itoa (c .Process .Pid ))
195+ out = append (out , stripCtrlChars ( strconv .Itoa (c .Process .Pid ) ))
194196 }
195197 return strings .Join (out , " " )
196198}
199+
200+ // stripCtrlChars returns a sanitized string
201+ // the PID read from the HAProxy socket includes a trailing control character,
202+ // usually the multi‑byte separator that HAProxy puts at the end of the Runtime API response
203+ func stripCtrlChars (s string ) string {
204+ return strings .Map (func (r rune ) rune {
205+ if unicode .IsControl (r ) {
206+ return - 1
207+ }
208+ return r
209+ }, s )
210+ }
You can’t perform that action at this time.
0 commit comments