Merge pull request #4339 from greatroar/ioctl

backend, termstatus: fix ioctl calls for 64-bit big-endian platforms
This commit is contained in:
Michael Eischer authored and GitHub committed 2023-05-26 19:34:14 +02:00
commit 658aa4c0f7
2 files changed
+17 -17

No files matched your search

+6 -2
View File
@@ -18,6 +18,10 @@ func IsProcessBackground(fd uintptr) bool {
}
func isProcessBackground(fd uintptr) (bool, error) {
pid, err := unix.IoctlGetInt(int(fd), unix.TIOCGPGRP)
return pid != unix.Getpgrp(), err
// We need to use IoctlGetUint32 here, because pid_t is 32-bit even on
// 64-bit Linux. IoctlGetInt doesn't work on big-endian platforms:
// https://github.com/golang/go/issues/45585
// https://github.com/golang/go/issues/60429
pid, err := unix.IoctlGetUint32(int(fd), unix.TIOCGPGRP)
return int(pid) != unix.Getpgrp(), err
}