From b71b77fa77daccbd7f0cf73ffc4fcd70282877f7 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 8 Sep 2025 10:55:58 +0200 Subject: [PATCH] terminal: unexport tcgetpgrp, tcsetpgrp and getpgrp --- internal/terminal/background_unix.go | 4 ++-- internal/terminal/foreground_unix.go | 8 ++++---- internal/terminal/getpgrp_solaris.go | 2 +- internal/terminal/getpgrp_unix.go | 2 +- internal/terminal/tcgetpgrp_linux.go | 2 +- internal/terminal/tcgetpgrp_unix.go | 2 +- internal/terminal/tcsetpgrp_aix.go | 2 +- internal/terminal/tcsetpgrp_unix.go | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/terminal/background_unix.go b/internal/terminal/background_unix.go index 316466ce9..9564c7cde 100644 --- a/internal/terminal/background_unix.go +++ b/internal/terminal/background_unix.go @@ -16,9 +16,9 @@ func IsProcessBackground(fd uintptr) bool { } func isProcessBackground(fd int) (bg bool, err error) { - pgid, err := Tcgetpgrp(fd) + pgid, err := tcgetpgrp(fd) if err != nil { return false, err } - return pgid != Getpgrp(), nil + return pgid != getpgrp(), nil } diff --git a/internal/terminal/foreground_unix.go b/internal/terminal/foreground_unix.go index a3fb4d086..a4f15eccf 100644 --- a/internal/terminal/foreground_unix.go +++ b/internal/terminal/foreground_unix.go @@ -28,13 +28,13 @@ func startForeground(cmd *exec.Cmd) (bg func() error, err error) { } // only move child process to foreground if restic is in the foreground - prev, err := Tcgetpgrp(int(tty.Fd())) + prev, err := tcgetpgrp(int(tty.Fd())) if err != nil { _ = tty.Close() return nil, err } - self := Getpgrp() + self := getpgrp() if prev != self { debug.Log("restic is not controlling the tty; err = %v", err) if err := tty.Close(); err != nil { @@ -55,7 +55,7 @@ func startForeground(cmd *exec.Cmd) (bg func() error, err error) { } // move the command's process group into the foreground - err = Tcsetpgrp(int(tty.Fd()), cmd.Process.Pid) + err = tcsetpgrp(int(tty.Fd()), cmd.Process.Pid) if err != nil { _ = tty.Close() return nil, err @@ -66,7 +66,7 @@ func startForeground(cmd *exec.Cmd) (bg func() error, err error) { signal.Reset(unix.SIGTTOU) // reset the foreground process group - err = Tcsetpgrp(int(tty.Fd()), prev) + err = tcsetpgrp(int(tty.Fd()), prev) if err != nil { _ = tty.Close() return err diff --git a/internal/terminal/getpgrp_solaris.go b/internal/terminal/getpgrp_solaris.go index e326079c3..71e02e7bf 100644 --- a/internal/terminal/getpgrp_solaris.go +++ b/internal/terminal/getpgrp_solaris.go @@ -2,7 +2,7 @@ package terminal import "golang.org/x/sys/unix" -func Getpgrp() int { +func getpgrp() int { pid, _ := unix.Getpgrp() return pid } diff --git a/internal/terminal/getpgrp_unix.go b/internal/terminal/getpgrp_unix.go index 759c28513..c9fe1470f 100644 --- a/internal/terminal/getpgrp_unix.go +++ b/internal/terminal/getpgrp_unix.go @@ -4,4 +4,4 @@ package terminal import "golang.org/x/sys/unix" -func Getpgrp() int { return unix.Getpgrp() } +func getpgrp() int { return unix.Getpgrp() } diff --git a/internal/terminal/tcgetpgrp_linux.go b/internal/terminal/tcgetpgrp_linux.go index bc7e18342..b51796ace 100644 --- a/internal/terminal/tcgetpgrp_linux.go +++ b/internal/terminal/tcgetpgrp_linux.go @@ -2,7 +2,7 @@ package terminal import "golang.org/x/sys/unix" -func Tcgetpgrp(ttyfd int) (int, error) { +func tcgetpgrp(ttyfd int) (int, error) { // 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 diff --git a/internal/terminal/tcgetpgrp_unix.go b/internal/terminal/tcgetpgrp_unix.go index 6fd7de0a5..c24bc513f 100644 --- a/internal/terminal/tcgetpgrp_unix.go +++ b/internal/terminal/tcgetpgrp_unix.go @@ -4,6 +4,6 @@ package terminal import "golang.org/x/sys/unix" -func Tcgetpgrp(ttyfd int) (int, error) { +func tcgetpgrp(ttyfd int) (int, error) { return unix.IoctlGetInt(ttyfd, unix.TIOCGPGRP) } diff --git a/internal/terminal/tcsetpgrp_aix.go b/internal/terminal/tcsetpgrp_aix.go index 671b03a7a..f8e8b2972 100644 --- a/internal/terminal/tcsetpgrp_aix.go +++ b/internal/terminal/tcsetpgrp_aix.go @@ -2,7 +2,7 @@ package terminal import "golang.org/x/sys/unix" -func Tcsetpgrp(fd int, pid int) error { +func tcsetpgrp(fd int, pid int) error { // The second argument to IoctlSetPointerInt has type int on AIX, // but the constant overflows 64-bit int, hence the two-step cast. req := uint(unix.TIOCSPGRP) diff --git a/internal/terminal/tcsetpgrp_unix.go b/internal/terminal/tcsetpgrp_unix.go index 524f5d05a..4a2c1a12e 100644 --- a/internal/terminal/tcsetpgrp_unix.go +++ b/internal/terminal/tcsetpgrp_unix.go @@ -4,6 +4,6 @@ package terminal import "golang.org/x/sys/unix" -func Tcsetpgrp(fd int, pid int) error { +func tcsetpgrp(fd int, pid int) error { return unix.IoctlSetPointerInt(fd, unix.TIOCSPGRP, pid) }