mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
syscall: add Dup3 on Linux
With dup3, we can avoid an extra system call on some machines while holding syscall.ForkLock. Currently we have to syscall.Dup + syscall.CloseOnExec. On machines with Linux and a new enough kernel, this can just be dup3. R=golang-dev, r CC=golang-dev https://golang.org/cl/12170045
This commit is contained in:
parent
252c107f2f
commit
c8d49cf56f
4 changed files with 31 additions and 0 deletions
|
|
@ -310,6 +310,16 @@ func Dup2(oldfd int, newfd int) (err error) {
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Dup3(oldfd int, newfd int, flags int) (err error) {
|
||||
_, _, e1 := RawSyscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
|
||||
if e1 != 0 {
|
||||
err = e1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func EpollCreate(size int) (fd int, err error) {
|
||||
r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
|
||||
fd = int(r0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue