| // Program psx-signals validates that the psx mechanism can coexist |
| // with Go use of signals. This is an unprivilaged program derived |
| // from the sample code provided in this bug report: |
| // https://bugzilla.kernel.org/show_bug.cgi?id=210533 |
| "kernel.org/pub/linux/libs/security/libcap/psx" |
| sig := make(chan os.Signal, maxSig) |
| signal.Notify(sig, os.Interrupt) |
| fmt.Print("Toggling KEEP_CAPS ") |
| for i := 0; i < maxSig; i++ { |
| _, _, err := psx.Syscall3(syscall.SYS_PRCTL, prSetKeepCaps, uintptr(i&1), 0) |
| log.Fatalf("[%d] attempt to set KEEPCAPS (to %d) failed: %v", i, i%2, err) |
| fmt.Print("Wait 1 second to see if unwanted signals arrive...") |
| // Confirm no signals are delivered. |
| case <-time.After(1 * time.Second): |
| log.Fatalf("signal received: %v", info) |
| fmt.Println(" none arrived") |