proc/gdbserver: set child process pgrp as foreground group (#3205)
Newer versions of debugserver (which contain [1]) will spawn the target process on a new process group, when we detect that this happen, and we are a headless instance and stdin is a tty, make the child process' process group the controlling group for the terminal. [1] https://reviews.llvm.org/rG33ac4fddc7906ba712c50cd3a9b02ae041d751ab
This commit is contained in:
parent
b9a8bd7f41
commit
56eed898ec
@ -573,6 +573,13 @@ func LLDBLaunch(cmd []string, wd string, flags proc.LaunchFlags, debugInfoDirs [
|
|||||||
} else {
|
} else {
|
||||||
tgt, err = p.Dial(port, cmd[0], 0, debugInfoDirs, proc.StopLaunched)
|
tgt, err = p.Dial(port, cmd[0], 0, debugInfoDirs, proc.StopLaunched)
|
||||||
}
|
}
|
||||||
|
if p.conn.pid != 0 && foreground && isatty.IsTerminal(os.Stdin.Fd()) {
|
||||||
|
// Make the target process the controlling process of the tty if it is a foreground process.
|
||||||
|
err = tcsetpgrp(os.Stdin.Fd(), p.conn.pid)
|
||||||
|
if err != nil {
|
||||||
|
logflags.DebuggerLogger().Errorf("could not set controlling process: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
return tgt, err
|
return tgt, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ package gdbserial
|
|||||||
import (
|
import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func sysProcAttr(foreground bool) *syscall.SysProcAttr {
|
func sysProcAttr(foreground bool) *syscall.SysProcAttr {
|
||||||
@ -15,3 +17,7 @@ func sysProcAttr(foreground bool) *syscall.SysProcAttr {
|
|||||||
func foregroundSignalsIgnore() {
|
func foregroundSignalsIgnore() {
|
||||||
signal.Ignore(syscall.SIGTTOU, syscall.SIGTTIN)
|
signal.Ignore(syscall.SIGTTOU, syscall.SIGTTIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tcsetpgrp(fd uintptr, pid int) error {
|
||||||
|
return unix.IoctlSetPointerInt(int(fd), unix.TIOCSPGRP, pid)
|
||||||
|
}
|
||||||
|
@ -8,3 +8,7 @@ func sysProcAttr(foreground bool) *syscall.SysProcAttr {
|
|||||||
|
|
||||||
func foregroundSignalsIgnore() {
|
func foregroundSignalsIgnore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tcsetpgrp(fd uintptr, pid int) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user