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

Only used under Linux, no need to have it available on Process itself.
This commit is contained in:
Derek Parker
2015-10-09 17:21:41 -07:00
parent d8dd9c8d0e
commit 2e71cf2465
3 changed files with 6 additions and 6 deletions

View File

@ -54,7 +54,6 @@ type Process struct {
exited bool exited bool
ptraceChan chan func() ptraceChan chan func()
ptraceDoneChan chan interface{} ptraceDoneChan chan interface{}
comm string
} }
func New(pid int) *Process { func New(pid int) *Process {

View File

@ -29,8 +29,9 @@ const (
STATUS_ZOMBIE = 'Z' STATUS_ZOMBIE = 'Z'
) )
// Not actually needed for Linux. type OSProcessDetails struct {
type OSProcessDetails interface{} comm string
}
// Create and begin debugging a new process. First entry in // Create and begin debugging a new process. First entry in
// `cmd` is the program to run, and then rest are the arguments // `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 // removes newline character
comm = comm[:len(comm)-1] 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 { 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 { if wpid != 0 {
return wpid, &s, err return wpid, &s, err
} }
if status(pid, dbp.comm) == STATUS_ZOMBIE { if status(pid, dbp.os.comm) == STATUS_ZOMBIE {
return pid, nil, nil return pid, nil, nil
} }
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)

View File

@ -27,7 +27,7 @@ func (t *Thread) halt() (err error) {
} }
func (thread *Thread) stopped() bool { 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 return state == STATUS_TRACE_STOP
} }