Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
liming6
dcu-process-montor
Commits
2051442e
Commit
2051442e
authored
Dec 04, 2025
by
liming6
Browse files
fix 修改kill process功能bug
parent
fd13705b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
24 deletions
+10
-24
utils/pid.go
utils/pid.go
+1
-1
utils/utils_test.go
utils/utils_test.go
+9
-23
No files found.
utils/pid.go
View file @
2051442e
...
@@ -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
}
}
...
...
utils/utils_test.go
View file @
2051442e
...
@@ -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
))
}
}
}
cmd
,
err
:=
p
.
Cmdline
()
list
.
Sort
(
func
(
x
,
y
time
.
Time
)
int
{
if
err
!=
nil
{
if
x
.
After
(
y
)
{
t
.
Error
(
err
)
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
)
}
}
t
.
Logf
(
"%s
\n
"
,
cmd
)
SendSignal
([]
int32
{
286962
},
syscall
.
SIGKILL
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment