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 *attachSSH) Signal(signal ssh.Signal) error { defer trace.End(trace.Begin("")) msg := msgs.SignalMsg{Signal: signal} ok, err := t.channel.SendRequest(msgs.SignalReq, true, msg.Marshal()) if err == nil && !ok { return fmt.Errorf("unknown error") } if err != nil { return fmt.Errorf("signal error: %s", 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 }