Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Canread
Gopsutil
提交
c6c910cc
G
Gopsutil
项目概览
Canread
/
Gopsutil
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gopsutil
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c6c910cc
编写于
11月 22, 2021
作者:
T
Tom Barker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add additional process states.
上级
78065a7c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
15 deletion
+54
-15
v3/process/process.go
v3/process/process.go
+49
-14
v3/process/process_test.go
v3/process/process_test.go
+5
-1
未找到文件。
v3/process/process.go
浏览文件 @
c6c910cc
...
...
@@ -45,13 +45,30 @@ type Process struct {
// Process status
const
(
// Running marks a task a running or runnable (on the run queue)
Running
=
"running"
Sleep
=
"sleep"
Stop
=
"stop"
Idle
=
"idle"
Zombie
=
"zombie"
Wait
=
"wait"
Lock
=
"lock"
// Blocked marks a task waiting on a short, uninterruptable operation (usually IO)
Blocked
=
"blocked"
// Idle marks a task sleeping for more than about 20 seconds
Idle
=
"idle"
// Lock marks a task waiting to acquire a lock
Lock
=
"lock"
// Sleep marks task waiting for short, interruptable operation
Sleep
=
"sleep"
// Stop marks a stopped process
Stop
=
"stop"
// Wait marks an idle interrupt thread (or paging in pre 2.6.xx Linux)
Wait
=
"wait"
// Zombie marks a defunct process, terminated but not reaped by its parent
Zombie
=
"zombie"
// Solaris states. See https://github.com/collectd/collectd/blob/1da3305c10c8ff9a63081284cf3d4bb0f6daffd8/src/processes.c#L2115
Daemon
=
"daemon"
Detached
=
"detached"
System
=
"system"
Orphan
=
"orphan"
UnknownState
=
""
)
type
OpenFilesStat
struct
{
...
...
@@ -554,23 +571,41 @@ func (p *Process) Environ() ([]string, error) {
return
p
.
EnvironWithContext
(
context
.
Background
())
}
// convertStatusChar as reported by the ps command across different platforms.
func
convertStatusChar
(
letter
string
)
string
{
// Sources
// Darwin: http://www.mywebuniversity.com/Man_Pages/Darwin/man_ps.html
// FreeBSD: https://www.freebsd.org/cgi/man.cgi?ps
// Linux https://man7.org/linux/man-pages/man1/ps.1.html
// OpenBSD: https://man.openbsd.org/ps.1#state
// Solaris: https://github.com/collectd/collectd/blob/1da3305c10c8ff9a63081284cf3d4bb0f6daffd8/src/processes.c#L2115
switch
letter
{
case
"A"
:
return
Daemon
case
"D"
,
"U"
:
return
Blocked
case
"E"
:
return
Detached
case
"I"
:
return
Idle
case
"L"
:
return
Lock
case
"O"
:
return
Orphan
case
"R"
:
return
Running
case
"S"
:
return
Sleep
case
"T"
:
case
"T"
,
"t"
:
// "t" is used by Linux to signal stopped by the debugger during tracing
return
Stop
case
"I"
:
return
Idle
case
"Z"
:
return
Zombie
case
"W"
:
return
Wait
case
"L"
:
return
Lock
case
"Y"
:
return
System
case
"Z"
:
return
Zombie
default
:
return
""
return
UnknownState
}
}
v3/process/process_test.go
浏览文件 @
c6c910cc
...
...
@@ -660,7 +660,11 @@ func Test_CPUTimes(t *testing.T) {
func
Test_OpenFiles
(
t
*
testing
.
T
)
{
fp
,
err
:=
os
.
Open
(
"process_test.go"
)
defer
fp
.
Close
()
assert
.
Nil
(
t
,
err
)
defer
func
()
{
err
:=
fp
.
Close
()
assert
.
Nil
(
t
,
err
)
}()
pid
:=
os
.
Getpid
()
p
,
err
:=
NewProcess
(
int32
(
pid
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录