func (t *Toolbox) killHelper(session *SessionConfig, name string) error { if name == "" { name = string(ssh.SIGTERM) } if session.Cmd.Process == nil { return fmt.Errorf("the session %s hasn't launched yet", session.ID) } sig := new(msgs.SignalMsg) err := sig.FromString(name) if err != nil { return err } num := syscall.Signal(sig.Signum()) log.Infof("sending signal %s (%d) to %s", sig.Signal, num, session.ID) if err := session.Cmd.Process.Signal(num); err != nil { return fmt.Errorf("failed to signal %s: %s", session.ID, err) } return nil }
func (t *Toolbox) kill(name string) error { session := t.config.Sessions[t.config.ID] if name == "" { name = string(ssh.SIGTERM) } sig := new(msgs.SignalMsg) err := sig.FromString(name) if err != nil { return err } num := syscall.Signal(sig.Signum()) log.Infof("sending signal %s (%d) to %s", sig.Signal, num, session.ID) if err := session.Cmd.Process.Signal(num); err != nil { return fmt.Errorf("failed to signal %s: %s", session.ID, err) } return nil }