Skip to content

Commit

Permalink
solve the undefined: unix.Dup2 compile error on mips64le (#680)
Browse files Browse the repository at this point in the history
error in detail:
go build
../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 on linux/amd64, linux/mips64le is Dup3 instead.

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
  • Loading branch information
XiaodongLoong committed Jun 9, 2020
1 parent 6321024 commit 0624f75
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 5 deletions.
11 changes: 11 additions & 0 deletions internal/remote/output_interceptor_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build darwin

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup2(oldfd, newfd)
}
11 changes: 11 additions & 0 deletions internal/remote/output_interceptor_dragonfly.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build dragonfly

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup2(oldfd, newfd)
}
11 changes: 11 additions & 0 deletions internal/remote/output_interceptor_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build freebsd

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup2(oldfd, newfd)
}
12 changes: 12 additions & 0 deletions internal/remote/output_interceptor_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build linux
// +build !mips64le

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup2(oldfd, newfd)
}
12 changes: 12 additions & 0 deletions internal/remote/output_interceptor_linux_mips64le.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build linux
// +build mips64le

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup3(oldfd, newfd, 0)
}
11 changes: 11 additions & 0 deletions internal/remote/output_interceptor_netbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build netbsd

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup2(oldfd, newfd)
}
11 changes: 11 additions & 0 deletions internal/remote/output_interceptor_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build openbsd

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup2(oldfd, newfd)
}
11 changes: 11 additions & 0 deletions internal/remote/output_interceptor_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build solaris

package remote

import (
"golang.org/x/sys/unix"
)

func interceptorDupx(oldfd int, newfd int) {
unix.Dup2(oldfd, newfd)
}
7 changes: 2 additions & 5 deletions internal/remote/output_interceptor_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os"

"github.com/nxadm/tail"
"golang.org/x/sys/unix"
)

func NewOutputInterceptor() OutputInterceptor {
Expand Down Expand Up @@ -36,10 +35,8 @@ func (interceptor *outputInterceptor) StartInterceptingOutput() error {
return err
}

// 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)
interceptorDupx(int(interceptor.redirectFile.Fd()), 1)
interceptorDupx(int(interceptor.redirectFile.Fd()), 2)

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

0 comments on commit 0624f75

Please sign in to comment.