github.com/huandu/go@v0.0.0-20151114150818-04e615e41150/misc/cgo/test/issue6997_linux.c (about) 1 // Copyright 2014 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 #include <pthread.h> 6 #include <stdio.h> 7 #include <unistd.h> 8 9 static pthread_t thread; 10 11 static void* threadfunc(void* dummy) { 12 while(1) { 13 sleep(1); 14 } 15 } 16 17 int StartThread() { 18 return pthread_create(&thread, NULL, &threadfunc, NULL); 19 } 20 21 int CancelThread() { 22 void *r; 23 pthread_cancel(thread); 24 pthread_join(thread, &r); 25 return (r == PTHREAD_CANCELED); 26 }