github.com/JimmyHuang454/JLS-go@v0.0.0-20230831150107-90d536585ba0/internal/poll/sock_cloexec.go (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // This file implements accept for platforms that provide a fast path for 6 // setting SetNonblock and CloseOnExec. 7 8 //go:build dragonfly || freebsd || (linux && !arm) || netbsd || openbsd || solaris 9 10 package poll 11 12 import "syscall" 13 14 // Wrapper around the accept system call that marks the returned file 15 // descriptor as nonblocking and close-on-exec. 16 func accept(s int) (int, syscall.Sockaddr, string, error) { 17 ns, sa, err := Accept4Func(s, syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC) 18 if err != nil { 19 return -1, sa, "accept4", err 20 } 21 return ns, sa, "", nil 22 }