From e4a381f9f43e555884be6457e74af0c1ac7a79ee Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Fri, 25 Oct 2019 15:25:52 -0500 Subject: [PATCH] Start the plugin using the configured stdin When the command client had a stdin already configured, use that instead of os.stdin when starting the plugin. --- client.go | 6 +++++- client_test.go | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index a6def2a7..82b9247a 100644 --- a/client.go +++ b/client.go @@ -526,7 +526,11 @@ func (c *Client) Start() (addr net.Addr, err error) { cmd := c.config.Cmd cmd.Env = append(cmd.Env, os.Environ()...) cmd.Env = append(cmd.Env, env...) - cmd.Stdin = os.Stdin + + // Use the client's stdin if configured, otherwise fallback to os.stdin + if cmd.Stdin == nil { + cmd.Stdin = os.Stdin + } cmdStdout, err := cmd.StdoutPipe() if err != nil { diff --git a/client_test.go b/client_test.go index 799346b6..19f645ba 100644 --- a/client_test.go +++ b/client_test.go @@ -728,11 +728,8 @@ func TestClient_Stdin(t *testing.T) { t.Fatalf("error: %s", err) } - oldStdin := os.Stdin - defer func() { os.Stdin = oldStdin }() - os.Stdin = tf - process := helperProcess("stdin") + process.Stdin = tf c := NewClient(&ClientConfig{ Cmd: process, HandshakeConfig: testHandshake,