Skip to content

Commit

Permalink
stdin pipe needs to be closed in case program continues to expect input
Browse files Browse the repository at this point in the history
  • Loading branch information
progrium committed Jul 25, 2016
1 parent 456459e commit ff9cab1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ NAME=sshfront
OWNER=gliderlabs
ARCH=$(shell uname -m)
RMFLAG=--rm
VERSION=0.2.0
VERSION=0.2.1

build:
mkdir -p build/Linux && GOOS=linux CGO_ENABLED=0 go build -a \
-ldflags "-X main.Version $(VERSION)" \
-ldflags "-X main.Version=$(VERSION)" \
-installsuffix cgo \
-o build/Linux/$(NAME)
mkdir -p build/Darwin && GOOS=darwin CGO_ENABLED=0 go build -a \
-ldflags "-X main.Version $(VERSION)" \
-ldflags "-X main.Version=$(VERSION)" \
-installsuffix cgo \
-o build/Darwin/$(NAME)

Expand Down
3 changes: 3 additions & 0 deletions example/stdinecho
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
echo "Stdin:"
cat
5 changes: 4 additions & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ func (h *sshHandler) handleExec(req *ssh.Request) {
h.channel.Close()
return
}
go io.Copy(stdinPipe, h.channel)
go func() {
defer stdinPipe.Close()
io.Copy(stdinPipe, h.channel)
}()

if req.WantReply {
req.Reply(true, nil)
Expand Down

0 comments on commit ff9cab1

Please sign in to comment.