Pass kill signal to ptrace_detach

This commit is contained in:
Derek Parker 2015-05-01 15:50:29 -05:00
parent e8edb043d7
commit 6cadeb41fc
3 changed files with 18 additions and 2 deletions

@ -6,6 +6,14 @@ import (
sys "golang.org/x/sys/unix"
)
func PtraceDetach(tid, sig int) error {
_, _, err := sys.Syscall6(sys.SYS_PTRACE, sys.PT_DETACH, uintptr(tid), 1, uintptr(sig), 0, 0)
if err != syscall.Errno(0) {
return err
}
return nil
}
func PtraceCont(tid, sig int) error {
_, _, err := sys.Syscall6(sys.SYS_PTRACE, sys.PTRACE_CONT, uintptr(tid), 1, uintptr(sig), 0, 0)
if err != syscall.Errno(0) {

@ -7,6 +7,14 @@ import (
sys "golang.org/x/sys/unix"
)
func PtraceDetach(tid, sig int) error {
_, _, err := sys.Syscall6(sys.SYS_PTRACE, sys.PTRACE_DETACH, uintptr(tid), 1, uintptr(sig), 0, 0)
if err != syscall.Errno(0) {
return err
}
return nil
}
func PtraceCont(tid, sig int) error {
return sys.PtraceCont(tid, sig)
}

@ -137,7 +137,7 @@ func (d *Debugger) Run() error {
// Kill the process if requested
if s.KillProcess {
if err := proctl.PtraceCont(d.process.Pid, int(sys.SIGINT)); err == nil {
if err := proctl.PtraceDetach(d.process.Pid, int(sys.SIGINT)); err == nil {
log.Print("killed process")
} else {
log.Printf("couldn't kill process: %s", err)
@ -145,7 +145,7 @@ func (d *Debugger) Run() error {
} else {
// Detach
if !d.process.Exited() {
if err := sys.PtraceDetach(d.process.Pid); err == nil {
if err := proctl.PtraceDetach(d.process.Pid, 0); err == nil {
log.Print("detached from process")
} else {
log.Printf("couldn't detach from process: %s", err)