Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Added sigterm options to "d" command. #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,15 @@ func eventLoop() {
ui.Render(proc)
case "d":
if previousKey == "d" {
proc.KillProc()
proc.KillProc("SIGTERM")
}
case "3":
if previousKey == "d" {
proc.KillProc("SIGQUIT")
}
case "9":
if previousKey == "d" {
proc.KillProc("SIGKILL")
}
case "<Tab>":
proc.ToggleShowingGroupedProcs()
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions src/widgets/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down