mirror of
https://git.kernel.org/pub/scm/libs/libcap/libcap.git
synced 2026-01-27 01:44:26 +00:00
The CGO_ENABLED=0 failure mode is discussed in: https://github.com/golang/go/issues/50113 At the present time, this only passes when the psx package is compiled CGO_ENABLED=1. The problem being that a blocking read cannot be interrupted by the CGO_ENABLED=0 build of package "psx". It does not deadlock when compiled CGO_ENABLED=1 because the psx signal wakes the reading thread up back into user space. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
26 lines
401 B
Go
26 lines
401 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"syscall"
|
|
"time"
|
|
|
|
"kernel.org/pub/linux/libs/security/libcap/psx"
|
|
)
|
|
|
|
const prSetKeepCaps = 8
|
|
|
|
func main() {
|
|
r, w, err := os.Pipe()
|
|
if err != nil {
|
|
log.Fatalf("failed to obtain pipe: %v", err)
|
|
}
|
|
data := make([]byte, 2+r.Fd())
|
|
go r.Read(data)
|
|
time.Sleep(500 * time.Millisecond)
|
|
psx.Syscall3(syscall.SYS_PRCTL, prSetKeepCaps, 1, 0)
|
|
w.Close()
|
|
r.Close()
|
|
}
|