From 0aa3d7ffe2526883a9513c7daed9febaa2ff996d Mon Sep 17 00:00:00 2001 From: Xiaodong Liu Date: Thu, 28 May 2020 14:32:54 +0800 Subject: [PATCH] solve the undefined: unix.Dup2 compile error on mips64le 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 --- internal/remote/output_interceptor_unix.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/remote/output_interceptor_unix.go b/internal/remote/output_interceptor_unix.go index 774967db66..cfe5e9db64 100644 --- a/internal/remote/output_interceptor_unix.go +++ b/internal/remote/output_interceptor_unix.go @@ -38,8 +38,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})