mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-11-28 07:21:21 +08:00
pkg/sys: Unify select_{linux,bsd}.go.
This commit is contained in:
parent
995879dcb6
commit
f7a5b6002a
|
@ -1,23 +0,0 @@
|
|||
// +build linux
|
||||
|
||||
package sys
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout time.Duration) error {
|
||||
// On ARM64, MIPS64 and MIPS64LE, unix.Select is emulated in userland and
|
||||
// will dereference timeout. In that case, we use Pselect to work around the
|
||||
// problem. Bug: https://github.com/golang/go/issues/24189
|
||||
|
||||
var ptimespec *unix.Timespec
|
||||
if timeout >= 0 {
|
||||
timespec := unix.NsecToTimespec(int64(timeout))
|
||||
ptimespec = ×pec
|
||||
}
|
||||
_, err := unix.Pselect(nfd, r.s(), w.s(), e.s(), ptimespec, nil)
|
||||
return err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// +build !windows
|
||||
// +build !windows,!plan9
|
||||
|
||||
package sys
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
// +build !windows,!plan9
|
||||
|
||||
package sys
|
||||
|
||||
|
@ -14,5 +14,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout time.Duration) error
|
|||
timeval := unix.NsecToTimeval(int64(timeout))
|
||||
ptimeval = &timeval
|
||||
}
|
||||
return unix.Select(nfd, r.s(), w.s(), e.s(), ptimeval)
|
||||
_, err := unix.Select(nfd, r.s(), w.s(), e.s(), ptimeval)
|
||||
return err
|
||||
}
|
Loading…
Reference in New Issue
Block a user