Blob


1 #include <pthread.h>
2 #include <utf.h>
3 #include <fmt.h>
5 pthread_key_t key;
7 void
8 pexit(void *v)
9 {
10 int s;
12 pthread_setspecific(key, (void*)1);
13 switch(fork()){
14 case -1:
15 fprint(2, "fork: %r\n");
16 case 0:
17 _exit(0);
18 default:
19 wait(&s);
20 }
21 pthread_exit(0);
22 }
24 int
25 main(int argc, char *argv[])
26 {
27 int i;
28 pthread_t pid;
30 pthread_key_create(&key, 0);
31 for(i=0;; i++){
32 print("%d\n", i);
33 if(pthread_create(&pid, 0, pexit, 0) < 0){
34 fprint(2, "pthread_create: %r\n");
35 abort();
36 }
37 }
38 }