github.com/golang/gofrontend@v0.0.0-20240429183944-60f985a78526/libgo/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 // +build !android 6 7 #include <pthread.h> 8 #include <stdio.h> 9 #include <unistd.h> 10 11 static pthread_t thread; 12 13 static void* threadfunc(void* dummy) { 14 while(1) { 15 sleep(1); 16 } 17 } 18 19 int StartThread() { 20 return pthread_create(&thread, NULL, &threadfunc, NULL); 21 } 22 23 int CancelThread() { 24 void *r; 25 pthread_cancel(thread); 26 pthread_join(thread, &r); 27 return (r == PTHREAD_CANCELED); 28 }