* tree-vect-loop-manip.c (vect_do_peeling): Do not use
[official-gcc.git] / libgo / misc / cgo / test / setgid_linux.go
blob6773f94d3d6816c6cbdab8e827e22a908b70ef18
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Test that setgid does not hang on GNU/Linux.
6 // See https://golang.org/issue/3871 for details.
8 package cgotest
11 #include <sys/types.h>
12 #include <unistd.h>
14 import "C"
16 import (
17 "os"
18 "os/signal"
19 "syscall"
20 "testing"
21 "time"
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
39 func testSetgid(t *testing.T) {
40 if !runTestSetgid() {
41 t.Error("setgid hung")
44 // Now try it again after using signal.Notify.
45 signal.Notify(make(chan os.Signal, 1), syscall.SIGINT)
46 if !runTestSetgid() {
47 t.Error("setgid hung after signal.Notify")