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. 4 5 // Test that setgid does not hang on GNU/Linux. 6 // See https://golang.org/issue/3871 for details. 7 8 package cgotest 9 10 /* 11 #include <sys/types.h> 12 #include <unistd.h> 13 */ 14 import "C" 15 16 import ( 17 "testing" 18 "time" 19 ) 20 21 func testSetgid(t *testing.T) { 22 c := make(chan bool) 23 go func() { 24 C.setgid(0) 25 c <- true 26 }() 27 select { 28 case <-c: 29 case <-time.After(5 * time.Second): 30 t.Error("setgid hung") 31 } 32 } 33