delve/pkg/proc/gdbserial/gdbserver_unix.go
Alessandro Arzilli a35b902ecf
gdbserial: continue if tcsetpgrp fails (#3211)
Do not stop if tcsetpgrp errors, also only do it if the target process
got its own process group.

Fixes #3210
2022-12-12 08:36:48 -08:00

28 lines
548 B
Go

//go:build linux || darwin || freebsd
// +build linux darwin freebsd
package gdbserial
import (
"os/signal"
"syscall"
"golang.org/x/sys/unix"
)
func sysProcAttr(foreground bool) *syscall.SysProcAttr {
return &syscall.SysProcAttr{Setpgid: true, Pgid: 0, Foreground: foreground}
}
func foregroundSignalsIgnore() {
signal.Ignore(syscall.SIGTTOU, syscall.SIGTTIN)
}
func tcsetpgrp(fd uintptr, pid int) error {
pgid, _ := syscall.Getpgid(pid)
if pid == pgid {
return unix.IoctlSetPointerInt(int(fd), unix.TIOCSPGRP, pid)
}
return nil
}