diff --git a/proc/proc_linux.go b/proc/proc_linux.go index 8aad8fa9ed4c8da471fa4f9eb51dffb03f2260ba..fc5751e8ea031413e99774ef823f96cdef4934f1 100644 --- a/proc/proc_linux.go +++ b/proc/proc_linux.go @@ -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 } } diff --git a/proc/proc_unix_test.go b/proc/proc_unix_test.go new file mode 100644 index 0000000000000000000000000000000000000000..4168f87f41118630e48100c8def740415e8d1961 --- /dev/null +++ b/proc/proc_unix_test.go @@ -0,0 +1,31 @@ +// +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) + } + }) +} diff --git a/proc/threads_linux.go b/proc/threads_linux.go index 88a89adcf70f0f486211f69dbd860b4e11c9cc8b..f1d649dbe1d2cf3bf030153804d4eab08279f42d 100644 --- a/proc/threads_linux.go +++ b/proc/threads_linux.go @@ -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 }