Skip to content

Commit

Permalink
internal/poll: update SOCK_CLOEXEC comment
Browse files Browse the repository at this point in the history
For #45964
For #59359

Change-Id: I9f8f4c17ccd9711f81d152953a5e6aea50c6a28f
Reviewed-on: https://go-review.googlesource.com/c/go/+/501636
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
  • Loading branch information
ianlancetaylor authored and gopherbot committed Jun 7, 2023
1 parent 7f26e9e commit 1ee729c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/internal/poll/sock_cloexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import "syscall"
// descriptor as nonblocking and close-on-exec.
func accept(s int) (int, syscall.Sockaddr, string, error) {
ns, sa, err := Accept4Func(s, syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC)
// On Linux the accept4 system call was introduced in 2.6.28
// kernel and on FreeBSD it was introduced in 10 kernel. If we
// get an ENOSYS error on both Linux and FreeBSD, or EINVAL
// error on Linux, fall back to using accept.
// TODO: We can remove the fallback on Linux and *BSD,
// as currently supported versions all support accept4
// with SOCK_CLOEXEC, but Solaris does not. See issue #59359.
switch err {
case nil:
return ns, sa, "", nil
Expand Down

0 comments on commit 1ee729c

Please sign in to comment.