From fd75fb78cf09b2ade707439bc6386d8a31ac29a2 Mon Sep 17 00:00:00 2001 From: absolutelightning Date: Mon, 3 Jul 2023 20:40:27 +0530 Subject: [PATCH] fix dialing of npipe --- command/connect/envoy/exec_windows.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/command/connect/envoy/exec_windows.go b/command/connect/envoy/exec_windows.go index e4ac82f0c2..92d50c4fc3 100644 --- a/command/connect/envoy/exec_windows.go +++ b/command/connect/envoy/exec_windows.go @@ -17,39 +17,32 @@ func makeBootstrapPipe(bootstrapJSON []byte) (string, error) { pipeFile := filepath.Join(os.TempDir(), fmt.Sprintf("envoy-%x-bootstrap.json", time.Now().UnixNano()+int64(os.Getpid()))) - pipeConn, err := npipe.Dial(pipeFile) + binary, args, err := execArgs("connect", "envoy", "pipe-bootstrap", pipeFile) if err != nil { - return tempFile, err + return pipeFile, err } - defer pipeConn.close() - - binary, args, err := execArgs("connect", "envoy", "pipe-bootstrap", pipeFile) + // Dial the named pipe + pipeConn, err := npipe.Dial(pipeFile) if err != nil { return pipeFile, err } + defer pipeConn.Close() // Start the command to connect to the named pipe cmd := exec.Command(binary, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - stdin, err := cmd.StdinPipe() - if err != nil { - return pipeFile, err - } + cmd.Stdin = pipeConn - // Start the command and write the config + // Start the command err = cmd.Start() if err != nil { return pipeFile, err } // Write the config - _, err = stdin.Write(bootstrapJSON) - if err != nil { - return pipeFile, err - } - err = stdin.Close() + _, err = pipeConn.Write(bootstrapJSON) if err != nil { return pipeFile, err }