Files
go-ts/cmd/tui/noise_linux.go

25 lines
477 B
Go
Raw Permalink Normal View History

//go:build linux
package main
import (
"os"
"golang.org/x/sys/unix"
)
func redirectStderr(f *os.File) {
if f == nil {
// Silence altogether if no debug file
null, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0)
if err == nil {
_ = unix.Dup2(int(null.Fd()), int(os.Stderr.Fd()))
}
return
}
// Redirect fd 2 (stderr) to our debug file
// This captures C-level library noise (ALSA, PortAudio) into the log
_ = unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
}