Skip to content

Commit

Permalink
solve the undefined: unix.Dup2 compile error on mips64le
Browse files Browse the repository at this point in the history
error in detail:
../internal/remote/output_interceptor_unix.go:41:2: undefined: unix.Dup2
../internal/remote/output_interceptor_unix.go:42:2: undefined: unix.Dup2
there is Dup2 syscall only on amd64, other arch is Dup3 instead.

Signed-off-by: Xiaodong Liu <[email protected]>
  • Loading branch information
XiaodongLoong committed May 28, 2020
1 parent c6d7afb commit 7e9b5ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/remote/output_interceptor_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"io/ioutil"
"os"
"runtime"

"github.com/nxadm/tail"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -38,8 +39,14 @@ func (interceptor *outputInterceptor) StartInterceptingOutput() error {

// This might call Dup3 if the dup2 syscall is not available, e.g. on
// linux/arm64 or linux/riscv64
unix.Dup2(int(interceptor.redirectFile.Fd()), 1)
unix.Dup2(int(interceptor.redirectFile.Fd()), 2)
switch {
case runtime.GOOS == "linux" && runtime.GOARCH == "amd64":
unix.Dup2(int(interceptor.redirectFile.Fd()), 1)
unix.Dup2(int(interceptor.redirectFile.Fd()), 2)
default:
unix.Dup3(int(interceptor.redirectFile.Fd()), 1, 0)
unix.Dup3(int(interceptor.redirectFile.Fd()), 2, 0)
}

if interceptor.streamTarget != nil {
interceptor.tailer, _ = tail.TailFile(interceptor.redirectFile.Name(), tail.Config{Follow: true})
Expand Down

0 comments on commit 7e9b5ad

Please sign in to comment.