提交 03792601 编写于 作者: A aarzilli 提交者: Derek Parker

proc: bugfix: propagate signals we don't handle to inferior

Fixes #419 (partial)
上级 63a66082
......@@ -317,7 +317,10 @@ func (dbp *Process) trapWait(pid int) (*Thread, error) {
}
if th != nil {
// TODO(dp) alert user about unexpected signals here.
if err := th.Continue(); err != nil {
if err := th.resumeWithSig(int(status.StopSignal())); err != nil {
if err == sys.ESRCH {
return nil, ProcessExitedError{Pid: dbp.Pid}
}
return nil, err
}
}
......
// +build linux darwin
package proc
import (
"testing"
"time"
"syscall"
protest "github.com/derekparker/delve/proc/test"
)
func TestIssue419(t *testing.T) {
// SIGINT directed at the inferior should be passed along not swallowed by delve
withTestProcess("issue419", t, func(p *Process, fixture protest.Fixture) {
go func() {
for {
if p.Running() {
time.Sleep(2 * time.Second)
err := syscall.Kill(p.Pid, syscall.SIGINT)
assertNoError(err, t, "syscall.Kill")
return
}
}
}()
err := p.Continue()
if _, exited := err.(ProcessExitedError); !exited {
t.Fatalf("Unexpected error after Continue(): %v\n", err)
}
})
}
......@@ -33,9 +33,13 @@ func (t *Thread) stopped() bool {
return state == StatusTraceStop
}
func (t *Thread) resume() (err error) {
func (t *Thread) resume() error {
return t.resumeWithSig(0)
}
func (t *Thread) resumeWithSig(sig int) (err error) {
t.running = true
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.ID, 0) })
t.dbp.execPtraceFunc(func() { err = PtraceCont(t.ID, sig) })
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册