Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
x/crypto/ssh: Session.Wait() hangs while reading from msg channel after sending EOF to os.Stdin #6088
Hi, I'm using go.crypto/ssh to implement an ssh client. I connected os.Stdin/Stdout/Stderr to Sesion.Stdin/Stdout/Stderr, allocated a PTY and started a shell. Sending EOF to stdin will cause Session.Wait() to never return while waiting for a message or close() on clientChan.msg. The expected behavior here would be for go.crypto/ssh to catch the EOF from Session.Stdin, send an eof to the remote side's program. Currently, it seems to just kill Stdin locally and hang it. It might be that the remote program is not a shell, and some program like cat. In that case, an EOF would simply stop the remote cat process. If it were the shell, the shell would quit, and send a channel close message back to go.crypto/ssh, indicating the session is done. My program can be seen here: https://bitbucket.org/mischief/scpu/src/51d57a77fcb4799b99424aac782f4ba061b1df01/scpu.go?at=default I'm using go tip, and I'm testing this on debian 7 and 9front hosts, and connecting to an openbsd 5.3 server. Incriminating backtrace after sending EOF: gdb$ goroutine 1 bt #0 0x0000000000417a06 in runtime.park (unlockf=void, lock=void, reason=void) at /srv/go/src/pkg/runtime/proc.c:1224 #1 0x00000000004055f3 in runtime.chanrecv (c=void, ep=void, selected=void, received=void) at /srv/go/src/pkg/runtime/chan.c:391 #2 0x0000000000405a75 in runtime.chanrecv2 (t=void, c=void) at /srv/go/src/pkg/runtime/chan.c:464 #3 0x0000000000432b76 in code.google.com/p/go.crypto/ssh.(*Session).wait (s=0xc210036770, ~anon0=...) at /tmp/scpu/src/code.google.com/p/go.crypto/ssh/session.go:415 #4 0x0000000000432a23 in code.google.com/p/go.crypto/ssh.(*Session).Wait (s=0xc210036770, ~anon0=...) at /tmp/scpu/src/code.google.com/p/go.crypto/ssh/session.go:397 #5 0x000000000040187c in main.interactive (session=0xc210036770, ~anon1=...) at /tmp/scpu/src/bitbucket.org/mischief/scpu/scpu.go:99 #6 0x000000000040145a in main.main () at /tmp/scpu/src/bitbucket.org/mischief/scpu/scpu.go:74 #7 0x0000000000415954 in runtime.main () at /srv/go/src/pkg/runtime/proc.c:182 #8 0x0000000000417bd0 in ?? () at /srv/go/src/pkg/runtime/proc.c:1267 #9 0x0000000000000000 in ?? ()