Skip to content

Commit

Permalink
gdbserial: continue if tcsetpgrp fails (#3211)
Browse files Browse the repository at this point in the history
Do not stop if tcsetpgrp errors, also only do it if the target process
got its own process group.

Fixes #3210
  • Loading branch information
aarzilli authored Dec 12, 2022
1 parent f07be48 commit a35b902
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion _scripts/test_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ if [ "$version" = "gotip" ]; then
cd -
else
echo Finding latest patch version for $version
version=$(curl 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.|^beta|^rc)' | sort -rV | head -1)
echo "Go $version on $arch"
version=$(curl 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.|beta|rc)' | sort -rV | head -1)
if [ "x$version" = "x" ]; then
version=$(curl 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.)' | sort -rV | head -1)
fi
getgo $version
fi

Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/gdbserial/gdbserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func LLDBLaunch(cmd []string, wd string, flags proc.LaunchFlags, debugInfoDirs [
}
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)
err := tcsetpgrp(os.Stdin.Fd(), p.conn.pid)
if err != nil {
logflags.DebuggerLogger().Errorf("could not set controlling process: %v", err)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/proc/gdbserial/gdbserver_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ func foregroundSignalsIgnore() {
}

func tcsetpgrp(fd uintptr, pid int) error {
return unix.IoctlSetPointerInt(int(fd), unix.TIOCSPGRP, pid)
pgid, _ := syscall.Getpgid(pid)
if pid == pgid {
return unix.IoctlSetPointerInt(int(fd), unix.TIOCSPGRP, pid)
}
return nil
}

0 comments on commit a35b902

Please sign in to comment.