Source file
src/os/signal/signal_linux_test.go
1
2
3
4
5
6
7 package signal
8
9 import (
10 "os"
11 "syscall"
12 "testing"
13 "time"
14 )
15
16 const prSetKeepCaps = 8
17
18
19
20
21
22 func TestAllThreadsSyscallSignals(t *testing.T) {
23 if _, _, err := syscall.AllThreadsSyscall(syscall.SYS_PRCTL, prSetKeepCaps, 0, 0); err == syscall.ENOTSUP {
24 t.Skip("AllThreadsSyscall disabled with cgo")
25 }
26
27 sig := make(chan os.Signal, 1)
28 Notify(sig, os.Interrupt)
29
30 for i := 0; i <= 100; i++ {
31 if _, _, errno := syscall.AllThreadsSyscall(syscall.SYS_PRCTL, prSetKeepCaps, uintptr(i&1), 0); errno != 0 {
32 t.Fatalf("[%d] failed to set KEEP_CAPS=%d: %v", i, i&1, errno)
33 }
34 }
35
36 select {
37 case <-time.After(10 * time.Millisecond):
38 case <-sig:
39 t.Fatal("unexpected signal")
40 }
41 Stop(sig)
42 }
43
View as plain text