From ddbc0c1b37f349abdac875e56a1f0c0fab9884dc Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Thu, 25 May 2023 17:20:42 +0200 Subject: [PATCH] termstatus: Fix IsProcessBackground for 64-bit big-endian Linux Fixes #4223. Verified with QEMU on linux/amd64. --- internal/ui/termstatus/background_linux.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/ui/termstatus/background_linux.go b/internal/ui/termstatus/background_linux.go index 2c32faf17..db96c2c53 100644 --- a/internal/ui/termstatus/background_linux.go +++ b/internal/ui/termstatus/background_linux.go @@ -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 }