From 2738c018e2a1a6d487854cad75332fe7eccebb37 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 24 Feb 2021 16:53:53 +0100 Subject: [PATCH] unix: fix Pipe2 on dragonfly The pipe2 on dragonfly still expects an fds array as an argument, but does not use it to return the file descriptors. Just pass the argument but ignore its value. This way the flags argument will be respected correctly. Change-Id: Id340653040999f31074eae01e9be4ea2088abae5 Reviewed-on: https://go-review.googlesource.com/c/sys/+/295870 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- unix/syscall_dragonfly.go | 7 +++++-- unix/zsyscall_dragonfly_amd64.go | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/unix/syscall_dragonfly.go b/unix/syscall_dragonfly.go index 474141b6..5af108a5 100644 --- a/unix/syscall_dragonfly.go +++ b/unix/syscall_dragonfly.go @@ -105,13 +105,16 @@ func Pipe(p []int) (err error) { return } -//sysnb pipe2(flags int) (r int, w int, err error) +//sysnb pipe2(p *[2]_C_int, flags int) (r int, w int, err error) func Pipe2(p []int, flags int) (err error) { if len(p) != 2 { return EINVAL } - p[0], p[1], err = pipe2(flags) + var pp [2]_C_int + // pipe2 on dragonfly takes an fds array as an argument, but still + // returns the file descriptors. + p[0], p[1], err = pipe2(&pp, flags) return err } diff --git a/unix/zsyscall_dragonfly_amd64.go b/unix/zsyscall_dragonfly_amd64.go index 556a0451..1b6eedfa 100644 --- a/unix/zsyscall_dragonfly_amd64.go +++ b/unix/zsyscall_dragonfly_amd64.go @@ -363,8 +363,8 @@ func pipe() (r int, w int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(flags int) (r int, w int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE2, uintptr(flags), 0, 0) +func pipe2(p *[2]_C_int, flags int) (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) r = int(r0) w = int(r1) if e1 != 0 {