提交 2e71cf24 编写于 作者: D Derek Parker

proc: refactor: move Process.comm to Process.os.comm

Only used under Linux, no need to have it available on Process itself.
上级 d8dd9c8d
......@@ -54,7 +54,6 @@ type Process struct {
exited bool
ptraceChan chan func()
ptraceDoneChan chan interface{}
comm string
}
func New(pid int) *Process {
......
......@@ -29,8 +29,9 @@ const (
STATUS_ZOMBIE = 'Z'
)
// Not actually needed for Linux.
type OSProcessDetails interface{}
type OSProcessDetails struct {
comm string
}
// Create and begin debugging a new process. First entry in
// `cmd` is the program to run, and then rest are the arguments
......@@ -321,7 +322,7 @@ func (dbp *Process) loadProcessInformation(wg *sync.WaitGroup) {
}
// removes newline character
comm = comm[:len(comm)-1]
dbp.comm = strings.Replace(string(comm), "%", "%%", -1)
dbp.os.comm = strings.Replace(string(comm), "%", "%%", -1)
}
func status(pid int, comm string) rune {
......@@ -369,7 +370,7 @@ func (dbp *Process) wait(pid, options int) (int, *sys.WaitStatus, error) {
if wpid != 0 {
return wpid, &s, err
}
if status(pid, dbp.comm) == STATUS_ZOMBIE {
if status(pid, dbp.os.comm) == STATUS_ZOMBIE {
return pid, nil, nil
}
time.Sleep(200 * time.Millisecond)
......
......@@ -27,7 +27,7 @@ func (t *Thread) halt() (err error) {
}
func (thread *Thread) stopped() bool {
state := status(thread.Id, thread.dbp.comm)
state := status(thread.Id, thread.dbp.os.comm)
return state == STATUS_TRACE_STOP
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册