Merge remote-tracking branch 'jrswab/otherSigTerms'

This commit is contained in:
Sean E. Russell 2020-02-13 13:38:45 -06:00
commit 1bf6926282
3 changed files with 21 additions and 6 deletions

View File

@ -322,7 +322,19 @@ func eventLoop(c gotop.Config, grid *layout.MyGrid) {
case "d":
if grid.Proc != nil {
if previousKey == "d" {
grid.Proc.KillProc()
grid.Proc.KillProc("SIGTERM")
}
}
case "3":
if grid.Proc != nil {
if previousKey == "d" {
grid.Proc.KillProc("SIGQUIT")
}
}
case "9":
if grid.Proc != nil {
if previousKey == "d" {
grid.Proc.KillProc("SIGKILL")
}
}
case "<Tab>":

View File

@ -22,7 +22,9 @@ Process navigation
Process actions:
- <Tab>: toggle process grouping
- dd: kill selected process or group of processes
- dd: kill selected process or group of processes with SIGTERM (15)
- d3: kill selected process or group of processes with SIGQUIT (3)
- d9: kill selected process or group of processes with SIGKILL (9)
Process sorting
- c: CPU
@ -50,7 +52,7 @@ func (self *HelpMenu) Resize(termWidth, termHeight int) {
textWidth = maxInt(len(line), textWidth)
}
textWidth += 2
textHeight := 22
textHeight := 28
x := (termWidth - textWidth) / 2
y := (termHeight - textHeight) / 2

View File

@ -182,14 +182,15 @@ func (self *ProcWidget) ToggleShowingGroupedProcs() {
self.convertProcsToTableRows()
}
// KillProc kills a process or group of processes depending on if we're displaying the processes grouped or not.
func (self *ProcWidget) KillProc() {
// KillProc kills a process or group of processes depending on if we're
// displaying the processes grouped or not.
func (self *ProcWidget) KillProc(sigName string) {
self.SelectedItem = ""
command := "kill"
if self.UniqueCol == 1 {
command = "pkill"
}
cmd := exec.Command(command, self.Rows[self.SelectedRow][self.UniqueCol])
cmd := exec.Command(command, "--signal", sigName, self.Rows[self.SelectedRow][self.UniqueCol])
cmd.Start()
cmd.Wait()
}