Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
}
}
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ 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
if cmd.Stdin == nil {
cmd.Stdin = os.Stdin
}

cmdStdout, err := cmd.StdoutPipe()
if err != nil {
Expand Down
27 changes: 27 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,34 @@ func TestClient_Stdin(t *testing.T) {
t.Fatal("process didn't exit cleanly")
}
}
func TestClient_StdinBuffer(t *testing.T) {

process := helperProcess("stdin")
process.Stdin = bytes.NewBufferString("hello")
c := NewClient(&ClientConfig{
Cmd: process,
HandshakeConfig: testHandshake,
Plugins: testPluginMap,
})
defer c.Kill()

_, err := c.Start()
if err != nil {
t.Fatalf("error: %s", err)
}

for {
if c.Exited() {
break
}

time.Sleep(50 * time.Millisecond)
}

if !process.ProcessState.Success() {
t.Fatal("process didn't exit cleanly")
}
}
func TestClient_SecureConfig(t *testing.T) {
// Test failure case
secureConfig := &SecureConfig{
Expand Down