From a4df01e1052dd2e312958d3e5e764fd65bac0086 Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Tue, 30 May 2017 20:08:27 +0200 Subject: [PATCH] proc/native/linux: call waitFast instead of wait in addThread and halt (#855) The condition that causes waitFast to fail can not happen in addThread and halt so we don't need to call the slower wait. --- pkg/proc/native/proc_linux.go | 4 ++-- pkg/proc/native/threads_linux.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/proc/native/proc_linux.go b/pkg/proc/native/proc_linux.go index b04274ec..01784322 100644 --- a/pkg/proc/native/proc_linux.go +++ b/pkg/proc/native/proc_linux.go @@ -120,7 +120,7 @@ func (dbp *Process) addThread(tid int, attach bool) (*Thread, error) { // if we truly don't have permissions. return nil, fmt.Errorf("could not attach to new thread %d %s", tid, err) } - pid, status, err := dbp.wait(tid, 0) + pid, status, err := dbp.waitFast(tid) if err != nil { return nil, err } @@ -131,7 +131,7 @@ func (dbp *Process) addThread(tid int, attach bool) (*Thread, error) { dbp.execPtraceFunc(func() { err = syscall.PtraceSetOptions(tid, syscall.PTRACE_O_TRACECLONE) }) if err == syscall.ESRCH { - if _, _, err = dbp.wait(tid, 0); err != nil { + if _, _, err = dbp.waitFast(tid); err != nil { return nil, fmt.Errorf("error while waiting after adding thread: %d %s", tid, err) } dbp.execPtraceFunc(func() { err = syscall.PtraceSetOptions(tid, syscall.PTRACE_O_TRACECLONE) }) diff --git a/pkg/proc/native/threads_linux.go b/pkg/proc/native/threads_linux.go index 57700581..d388f529 100644 --- a/pkg/proc/native/threads_linux.go +++ b/pkg/proc/native/threads_linux.go @@ -22,7 +22,7 @@ func (t *Thread) halt() (err error) { err = fmt.Errorf("halt err %s on thread %d", err, t.ID) return } - _, _, err = t.dbp.wait(t.ID, 0) + _, _, err = t.dbp.waitFast(t.ID) if err != nil { err = fmt.Errorf("wait err %s on thread %d", err, t.ID) return -- GitLab