2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 19:08:55 +00:00

termstatus: Fix IsProcessBackground for 64-bit big-endian Linux

Fixes #4223. Verified with QEMU on linux/amd64.
This commit is contained in:
greatroar 2023-05-25 17:20:42 +02:00
parent b50ff04cf3
commit ddbc0c1b37

View File

@ -18,6 +18,10 @@ func IsProcessBackground(fd uintptr) bool {
} }
func isProcessBackground(fd uintptr) (bool, error) { func isProcessBackground(fd uintptr) (bool, error) {
pid, err := unix.IoctlGetInt(int(fd), unix.TIOCGPGRP) // We need to use IoctlGetUint32 here, because pid_t is 32-bit even on
return pid != unix.Getpgrp(), err // 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
} }