@@ -5,10 +5,8 @@ import (
55 "os"
66 "os/signal"
77 "strconv"
8- "strings"
98 "sync"
109 "syscall"
11- "unicode"
1210
1311 "github.com/fsnotify/fsnotify"
1412 "github.com/snorwin/haproxy-reload-wrapper/pkg/exec"
@@ -136,7 +134,8 @@ func runInstance() {
136134 args := os .Args [1 :]
137135 l .RLock ()
138136 if len (cmds ) > 0 {
139- args = append (args , []string {"-x" , utils .LookupHAProxySocketPath (), "-sf" , pids ()}... )
137+ args = append (args , []string {"-x" , utils .LookupHAProxySocketPath (), "-sf" }... )
138+ args = append (args , pids ()... )
140139 }
141140 l .RUnlock ()
142141
@@ -184,27 +183,11 @@ func runInstance() {
184183 cmds = append (cmds , cmd )
185184}
186185
187- // pids returns the PID list as a space-separated string
188- func pids () string {
189- if len (cmds ) == 0 {
190- return ""
191- }
192-
186+ // pids returns the PID list
187+ func pids () []string {
193188 out := make ([]string , 0 , len (cmds ))
194189 for _ , c := range cmds {
195- out = append (out , stripCtrlChars ( strconv .Itoa (c .Process .Pid ) ))
190+ out = append (out , strconv .Itoa (c .Process .Pid ))
196191 }
197- return strings .Join (out , " " )
198- }
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 )
192+ return out
210193}
0 commit comments