fix: wait non-nil process

This commit is contained in:
Ryo Ota 2024-05-27 17:11:21 +09:00
parent f41ff25604
commit f6d96d1a78

View file

@ -31,9 +31,11 @@ func (s *Server) createPty(shell string, connection ssh.Channel) (*os.File, erro
Status: 0,
}))
connection.Close()
_, err := sh.Process.Wait()
if err != nil {
s.Logger.Info("failed to exit shell", err)
if sh.Process != nil {
_, err := sh.Process.Wait()
if err != nil {
s.Logger.Info("failed to exit shell", err)
}
}
s.Logger.Info("session closed")
}