提交 bba999b9 编写于 作者: A aarzilli

proc: bugfix: intermittent failures of TestRestart_afterExit

During process termination we seem to receive notifications of new
threads that die before we can add them, ignore them
上级 d81482c8
......@@ -116,6 +116,9 @@ func (dbp *Process) addThread(tid int, attach bool) (*Thread, error) {
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) })
if err == syscall.ESRCH {
return nil, err
}
if err != nil {
return nil, fmt.Errorf("could not set options for new traced thread %d %s", tid, err)
}
......@@ -265,9 +268,18 @@ func (dbp *Process) trapWait(pid int) (*Thread, error) {
}
th, err = dbp.addThread(int(cloned), false)
if err != nil {
if err == sys.ESRCH {
// thread died while we were adding it
continue
}
return nil, err
}
if err = th.Continue(); err != nil {
if err == sys.ESRCH {
// thread died while we were adding it
delete(dbp.Threads, th.Id)
continue
}
return nil, fmt.Errorf("could not continue new thread %d %s", cloned, err)
}
if err = dbp.Threads[int(wpid)].Continue(); err != nil {
......
......@@ -83,7 +83,7 @@ func TestRestart_afterExit(t *testing.T) {
}
state = <-c.Continue()
if !state.Exited {
t.Fatal("expected restarted process to have exited")
t.Fatalf("expected restarted process to have exited %v", state)
}
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册