Skip to content

x/sys/unix: Add Dup3 on FreeBSD #55935

@dveeden

Description

@dveeden

What version of Go are you using (go version)?

% go version
go version go1.19.1 freebsd/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
% go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dveeden/.cache/go-build"
GOENV="/home/dveeden/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/home/dveeden/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/dveeden/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go119"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go119/pkg/tool/freebsd_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v2"
AR="ar"
CC="cc"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4147625229=/tmp/go-build -gno-record-gcc-switches"

What did you do?

syscall.Dup3() is available on Linux, but not on FreeBSD. However the syscall seems to be present as indicated on the dup3(3) manpage.

A patch like this might work:

diff --git a/src/syscall/syscall_freebsd.go b/src/syscall/syscall_freebsd.go
index 0f3912644b..83d338554b 100644
--- a/src/syscall/syscall_freebsd.go
+++ b/src/syscall/syscall_freebsd.go
@@ -179,6 +179,7 @@ func Mknod(path string, mode uint32, dev uint64) (err error) {
 //sys  Close(fd int) (err error)
 //sys  Dup(fd int) (nfd int, err error)
 //sys  Dup2(from int, to int) (err error)
+//sys  Dup3(oldfd int, newfd int, flags int) (err error)
 //sys  Fchdir(fd int) (err error)
 //sys  Fchflags(fd int, flags int) (err error)
 //sys  Fchmod(fd int, mode uint32) (err error)

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.OS-FreeBSDcompiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions