Skip to content

Commit

Permalink
internal/remote: use unix.Dup2 instead of wrapping Dup2/Dup3 manually (
Browse files Browse the repository at this point in the history
…#761)

The latest version of the golang.org/x/sys/unix package already
implements func Dup2 using Dup3 on platforms which dont have the dup2
syscall. Use Dup2 and let x/sys/unix figure out the correct syscall.

This effectivly reverts PR #680. Verified that ginkgo still correctly
builds on linux/mips64le.
  • Loading branch information
tklauser authored Jan 19, 2021
1 parent 0c40583 commit c2b0e16
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 94 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/nxadm/tail v1.4.4
github.com/onsi/gomega v1.10.1
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f
golang.org/x/sys v0.0.0-20210112080510-489259a85091
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e
)

Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
11 changes: 0 additions & 11 deletions internal/remote/output_interceptor_darwin.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/remote/output_interceptor_dragonfly.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/remote/output_interceptor_freebsd.go

This file was deleted.

12 changes: 0 additions & 12 deletions internal/remote/output_interceptor_linux.go

This file was deleted.

12 changes: 0 additions & 12 deletions internal/remote/output_interceptor_linux_mips64le.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/remote/output_interceptor_netbsd.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/remote/output_interceptor_openbsd.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/remote/output_interceptor_solaris.go

This file was deleted.

7 changes: 5 additions & 2 deletions internal/remote/output_interceptor_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"

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

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

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

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

0 comments on commit c2b0e16

Please sign in to comment.