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) {
if v == 1 {
continue
}
p, err := process.NewProcess(1)
p, err := process.NewProcess(v)
if err != nil {
continue
}
......
......@@ -5,12 +5,12 @@ import (
"slices"
"strings"
"sync/atomic"
"syscall"
"testing"
"time"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/tree"
"github.com/emirpasic/gods/v2/lists/doublylinkedlist"
"github.com/emirpasic/gods/v2/maps/treemap"
"github.com/shirou/gopsutil/v4/process"
)
......@@ -198,28 +198,14 @@ func TestChild(t *testing.T) {
}
func TestCHar(t *testing.T) {
list := doublylinkedlist.New[time.Time]()
now := time.Now()
for i := range 10 {
if i%2 == 0 {
list.Add(now.Add(time.Duration(i) * time.Second))
} else {
list.Add(now.Add(time.Duration(-i) * time.Second))
}
p, err := process.NewProcess(286962)
if err != nil {
t.Error(err)
}
list.Sort(func(x, y time.Time) int {
if x.After(y) {
return 1
}
if x.Before(y) {
return -1
}
return 0
})
for _ = range list.Size() {
time, b := list.Get(0)
list.Remove(0)
t.Logf("%v: %v", time, b)
cmd, err := p.Cmdline()
if err != nil {
t.Error(err)
}
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