diff options
Diffstat (limited to 'misc/cgo/test/setgid_linux.go')
-rw-r--r-- | misc/cgo/test/setgid_linux.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/misc/cgo/test/setgid_linux.go b/misc/cgo/test/setgid_linux.go index 197f01fb7e..ca95e08359 100644 --- a/misc/cgo/test/setgid_linux.go +++ b/misc/cgo/test/setgid_linux.go @@ -14,11 +14,14 @@ package cgotest import "C" import ( + "os" + "os/signal" + "syscall" "testing" "time" ) -func testSetgid(t *testing.T) { +func runTestSetgid() bool { c := make(chan bool) go func() { C.setgid(0) @@ -26,7 +29,21 @@ func testSetgid(t *testing.T) { }() select { case <-c: + return true case <-time.After(5 * time.Second): + return false + } + +} + +func testSetgid(t *testing.T) { + if !runTestSetgid() { t.Error("setgid hung") } + + // Now try it again after using signal.Notify. + signal.Notify(make(chan os.Signal, 1), syscall.SIGINT) + if !runTestSetgid() { + t.Error("setgid hung after signal.Notify") + } } |