diff --git a/internal/remote/output_interceptor_unix.go b/internal/remote/output_interceptor_unix.go index 181b227e6..1235ad00c 100644 --- a/internal/remote/output_interceptor_unix.go +++ b/internal/remote/output_interceptor_unix.go @@ -6,7 +6,6 @@ import ( "errors" "io/ioutil" "os" - "syscall" ) func NewOutputInterceptor() OutputInterceptor { @@ -31,8 +30,12 @@ func (interceptor *outputInterceptor) StartInterceptingOutput() error { return err } - syscall.Dup2(int(interceptor.redirectFile.Fd()), 1) - syscall.Dup2(int(interceptor.redirectFile.Fd()), 2) + // Call a function in ./syscall_dup_*.go + // If building for everything other than linux_arm64, + // use a "normal" syscall.Dup2(oldfd, newfd) call. If building for linux_arm64 (which doesn't have syscall.Dup2) + // call syscall.Dup3(oldfd, newfd, 0). They are nearly identical, see: http://linux.die.net/man/2/dup3 + syscallDup(int(interceptor.redirectFile.Fd()), 1) + syscallDup(int(interceptor.redirectFile.Fd()), 2) return nil } diff --git a/internal/remote/syscall_dup_linux_arm64.go b/internal/remote/syscall_dup_linux_arm64.go new file mode 100644 index 000000000..5c59728ea --- /dev/null +++ b/internal/remote/syscall_dup_linux_arm64.go @@ -0,0 +1,11 @@ +// +build linux,arm64 + +package remote + +import "syscall" + +// linux_arm64 doesn't have syscall.Dup2 which ginkgo uses, so +// use the nearly identical syscall.Dup3 instead +func syscallDup(oldfd int, newfd int) (err error) { + return syscall.Dup3(oldfd, newfd, 0) +} \ No newline at end of file diff --git a/internal/remote/syscall_dup_unix.go b/internal/remote/syscall_dup_unix.go new file mode 100644 index 000000000..b0111d100 --- /dev/null +++ b/internal/remote/syscall_dup_unix.go @@ -0,0 +1,10 @@ +// +build !linux !arm64 +// +build !windows + +package remote + +import "syscall" + +func syscallDup(oldfd int, newfd int) (err error) { + return syscall.Dup2(oldfd, newfd) +} \ No newline at end of file