// Copyright 2023 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.//go:build unix || (js && wasm)package pollimporttypeSysFilestruct {// Writev cache. iovecs *[]syscall.Iovec}func ( *SysFile) () {}func ( *SysFile) ( int) error {// We don't use ignoringEINTR here because POSIX does not define // whether the descriptor is closed if close returns EINTR. // If the descriptor is indeed closed, using a loop would race // with some other goroutine opening a new descriptor. // (The Linux kernel guarantees that it is closed on an EINTR error.)returnCloseFunc()}// dupCloseOnExecOld is the traditional way to dup an fd and// set its O_CLOEXEC bit, using two system calls.func dupCloseOnExecOld( int) (int, string, error) {syscall.ForkLock.RLock()defersyscall.ForkLock.RUnlock() , := syscall.Dup()if != nil {return -1, "dup", }syscall.CloseOnExec()return , "", nil}// Fchdir wraps syscall.Fchdir.func ( *FD) () error {if := .incref(); != nil {return }defer .decref()returnsyscall.Fchdir(.Sysfd)}// ReadDirent wraps syscall.ReadDirent.// We treat this like an ordinary system call rather than a call// that tries to fill the buffer.func ( *FD) ( []byte) (int, error) {if := .incref(); != nil {return0, }defer .decref()for { , := ignoringEINTRIO(syscall.ReadDirent, .Sysfd, )if != nil { = 0if == syscall.EAGAIN && .pd.pollable() {if = .pd.waitRead(.isFile); == nil {continue } } }// Do not call eofError; caller does not expect to see io.EOF.return , }}// Seek wraps syscall.Seek.func ( *FD) ( int64, int) (int64, error) {if := .incref(); != nil {return0, }defer .decref()returnsyscall.Seek(.Sysfd, , )}
The pages are generated with Goldsv0.7.3-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.