-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccept_linux.go
More file actions
28 lines (23 loc) · 628 Bytes
/
accept_linux.go
File metadata and controls
28 lines (23 loc) · 628 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// ©Hayabusa Cloud Co., Ltd. 2025. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
//go:build linux
package sock
import (
"unsafe"
"code.hybscloud.com/zcall"
)
// accept4 wraps the accept4 syscall with SOCK_NONBLOCK and SOCK_CLOEXEC flags.
// Linux supports accept4 natively.
func accept4(fd int, addr unsafe.Pointer, addrlen unsafe.Pointer) (int, error) {
nfd, errno := zcall.Accept4(
uintptr(fd),
addr,
addrlen,
zcall.SOCK_NONBLOCK|zcall.SOCK_CLOEXEC,
)
if errno != 0 {
return -1, errFromErrno(errno)
}
return int(nfd), nil
}