Fix IsProcessBackground on Linux with stdin redirection
The previous implementation assumed that stdin was a terminal. It now checks the terminal's fd.
This commit is contained in:
parent
6003dada14
commit
f80b07b2c8
4 changed files with 36 additions and 15 deletions
19
internal/ui/termstatus/background_linux_test.go
Normal file
19
internal/ui/termstatus/background_linux_test.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package termstatus
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
func TestIsProcessBackground(t *testing.T) {
|
||||
tty, err := os.Open("/dev/tty")
|
||||
if err != nil {
|
||||
t.Skipf("can't open terminal: %v", err)
|
||||
}
|
||||
defer tty.Close()
|
||||
|
||||
_, err = isProcessBackground(tty.Fd())
|
||||
rtest.OK(t, err)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue