/
niceSOFT
/
libcap
Обзор
Документация
Войти
/
niceSOFT
/
libcap
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
cap/fd.go
26 строк
781 B
Andrew G. Morgan
Restore parity between libcap and the Go cap package
29 мар 2026, 17:45
29 мар 2026, 17:45
472547b
Код
Авторство
О чём код?
//go:build go1.12 // +build go1.12 package cap import "os" // fd returns the file descriptor of the file. This is a little more // elaborate than using file.Fd() as it works around Go's default of // locking system calls to threads when functions get raw access to // their file descriptor. We judge that behavior to not be needed in // our limited use case and don't want to burden applications with the // corresponding resource overhead of that thread pinning. // // See https://sites.google.com/site/fullycapable/getting-started-with-go/some-go-gotchas-with-psx-and-cap-packages func fd(file *os.File) uintptr { s, err := file.SyscallConn() if err != nil { return ^uintptr(0) } var exported uintptr s.Control(func(fd uintptr) { exported = fd }) return exported }