github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/logger/redirect_stderr_nix.go (about)

     1  // Copyright 2016 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  //go:build darwin || freebsd || netbsd || openbsd
     5  // +build darwin freebsd netbsd openbsd
     6  
     7  package logger
     8  
     9  import (
    10  	"os"
    11  	"syscall"
    12  )
    13  
    14  func tryRedirectStderrTo(f *os.File) error {
    15  	// Calling dup2 first closes the current stderr and then dups the new handle there.
    16  	return syscall.Dup2(int(f.Fd()), 2)
    17  }