Commit 2051442e authored by liming6's avatar liming6
Browse files

fix 修改kill process功能bug

parent fd13705b
...@@ -207,7 +207,7 @@ func SendSignal(pids []int32, sig syscall.Signal) { ...@@ -207,7 +207,7 @@ func SendSignal(pids []int32, sig syscall.Signal) {
if v == 1 { if v == 1 {
continue continue
} }
p, err := process.NewProcess(1) p, err := process.NewProcess(v)
if err != nil { if err != nil {
continue continue
} }
......
...@@ -5,12 +5,12 @@ import ( ...@@ -5,12 +5,12 @@ import (
"slices" "slices"
"strings" "strings"
"sync/atomic" "sync/atomic"
"syscall"
"testing" "testing"
"time" "time"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/tree" "github.com/charmbracelet/lipgloss/tree"
"github.com/emirpasic/gods/v2/lists/doublylinkedlist"
"github.com/emirpasic/gods/v2/maps/treemap" "github.com/emirpasic/gods/v2/maps/treemap"
"github.com/shirou/gopsutil/v4/process" "github.com/shirou/gopsutil/v4/process"
) )
...@@ -198,28 +198,14 @@ func TestChild(t *testing.T) { ...@@ -198,28 +198,14 @@ func TestChild(t *testing.T) {
} }
func TestCHar(t *testing.T) { func TestCHar(t *testing.T) {
list := doublylinkedlist.New[time.Time]() p, err := process.NewProcess(286962)
now := time.Now() if err != nil {
for i := range 10 { t.Error(err)
if i%2 == 0 {
list.Add(now.Add(time.Duration(i) * time.Second))
} else {
list.Add(now.Add(time.Duration(-i) * time.Second))
}
}
list.Sort(func(x, y time.Time) int {
if x.After(y) {
return 1
}
if x.Before(y) {
return -1
} }
return 0 cmd, err := p.Cmdline()
}) if err != nil {
for _ = range list.Size() { t.Error(err)
time, b := list.Get(0)
list.Remove(0)
t.Logf("%v: %v", time, b)
} }
t.Logf("%s \n", cmd)
SendSignal([]int32{286962}, syscall.SIGKILL)
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment