@@ -46,7 +46,7 @@ func createPty(s ssh.Session, shell string) {
4646 io .WriteString (s , "No ConPTY shell or ssh-shellhost enhanced shell available. " +
4747 "Please append 'cmd' to your ssh command to gain shell access, i.e. " +
4848 "'ssh <OPTIONS> <IP> cmd'.\n " )
49- s .Exit (1 )
49+ s .Exit (255 )
5050 return
5151 }
5252 log .Println ("Launching shell with ssh-shellhost.exe" )
@@ -60,7 +60,7 @@ func createPty(s ssh.Session, shell string) {
6060 // We use StdinPipe to avoid blocking on missing input
6161 if stdin , err := cmd .StdinPipe (); err != nil {
6262 log .Println ("Could not initialize stdinPipe" , err )
63- s .Exit (1 )
63+ s .Exit (255 )
6464 return
6565 } else {
6666 go func () {
@@ -80,10 +80,12 @@ func createPty(s ssh.Session, shell string) {
8080 case err := <- done :
8181 if err != nil {
8282 log .Println ("Session ended with error:" , err )
83- } else {
84- log . Println ( "Session ended normally" )
83+ s . Exit ( 255 )
84+ return
8585 }
86+ log .Println ("Session ended normally" )
8687 s .Exit (cmd .ProcessState .ExitCode ())
88+ return
8789
8890 case <- s .Context ().Done ():
8991 log .Printf ("Session terminated: %s" , s .Context ().Err ())
@@ -144,11 +146,12 @@ func createPty(s ssh.Session, shell string) {
144146 case result := <- done :
145147 if result .error != nil {
146148 log .Println ("Error waiting for process:" , err )
147- s .Exit (1 )
149+ s .Exit (255 )
148150 return
149151 }
150152 log .Printf ("Session ended normally, exit code %d" , result .ProcessState .ExitCode ())
151153 s .Exit (result .ProcessState .ExitCode ())
154+ return
152155
153156 case <- s .Context ().Done ():
154157 log .Printf ("Session terminated: %s" , s .Context ().Err ())
0 commit comments