1
2
3
4
5
6
7
8 package cgotest
9
10
14 import "C"
15
16 import (
17 "os"
18 "os/signal"
19 "syscall"
20 "testing"
21 "time"
22 )
23
24 func runTestSetgid() bool {
25 c := make(chan bool)
26 go func() {
27 C.setgid(0)
28 c <- true
29 }()
30 select {
31 case <-c:
32 return true
33 case <-time.After(5 * time.Second):
34 return false
35 }
36
37 }
38
39 func testSetgid(t *testing.T) {
40 if !runTestSetgid() {
41 t.Error("setgid hung")
42 }
43
44
45 signal.Notify(make(chan os.Signal, 1), syscall.SIGINT)
46 if !runTestSetgid() {
47 t.Error("setgid hung after signal.Notify")
48 }
49 }
50
View as plain text