mirror of
https://github.com/golang/sys.git
synced 2026-02-09 12:16:04 +03:00
unix: add methods to manipulate *FdSet
Add Set, Clear, IsSet and Zero methods to manipulate an *FdSet. These implement the same functionality as the FD_SET, FD_CLR, FD_ISSET and FD_ZERO macros in <sys/select.h>. Change-Id: I6b7bccb98e58ee5e719096ed5743f6edcd232840 Reviewed-on: https://go-review.googlesource.com/c/sys/+/205397 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
e8c54fb511
commit
ac3223d801
@@ -52,11 +52,10 @@ func TestSelect(t *testing.T) {
|
||||
}
|
||||
|
||||
rFdSet := &unix.FdSet{}
|
||||
fd := rr.Fd()
|
||||
// FD_SET(fd, rFdSet)
|
||||
rFdSet.Bits[fd/unix.NFDBITS] |= (1 << (fd % unix.NFDBITS))
|
||||
fd := int(rr.Fd())
|
||||
rFdSet.Set(fd)
|
||||
|
||||
n, err = unix.Select(int(fd+1), rFdSet, nil, nil, nil)
|
||||
n, err = unix.Select(fd+1, rFdSet, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Select: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user