github.com/tetratelabs/wazero@v1.2.1/internal/sysfs/select.go (about) 1 package sysfs 2 3 import ( 4 "time" 5 6 "github.com/tetratelabs/wazero/internal/platform" 7 ) 8 9 // _select exposes the select(2) syscall. This is named as such to avoid 10 // colliding with they keyword select while not exporting the function. 11 // 12 // # Notes on Parameters 13 // 14 // For convenience, we expose a pointer to a time.Duration instead of a pointer to a syscall.Timeval. 15 // It must be a pointer because `nil` means "wait forever". 16 // 17 // However, notice that select(2) may mutate the pointed Timeval on some platforms, 18 // for instance if the call returns early. 19 // 20 // This implementation *will not* update the pointed time.Duration value accordingly. 21 // 22 // See also: https://github.com/golang/sys/blob/master/unix/syscall_unix_test.go#L606-L617 23 // 24 // # Notes on the Syscall 25 // 26 // Because this is a blocking syscall, it will also block the carrier thread of the goroutine, 27 // preventing any means to support context cancellation directly. 28 // 29 // There are ways to obviate this issue. We outline here one idea, that is however not currently implemented. 30 // A common approach to support context cancellation is to add a signal file descriptor to the set, 31 // e.g. the read-end of a pipe or an eventfd on Linux. 32 // When the context is canceled, we may unblock a Select call by writing to the fd, causing it to return immediately. 33 // This however requires to do a bit of housekeeping to hide the "special" FD from the end-user. 34 func _select(n int, r, w, e *platform.FdSet, timeout *time.Duration) (int, error) { 35 return syscall_select(n, r, w, e, timeout) 36 }