diff options
| author | rsc <devnull@localhost> | 2004-12-25 21:56:33 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-12-25 21:56:33 +0000 |
| commit | 1544f90960275dc9211bde30329c3258e0e1bf38 (patch) | |
| tree | f55e7a73c03aaa24daa7cc2ad02822b921c477f9 /src/libthread/test/pthreadloop.c | |
| parent | 7788fd54094693384ef5c92c475656dba8819feb (diff) | |
| download | plan9port-1544f90960275dc9211bde30329c3258e0e1bf38.tar.gz plan9port-1544f90960275dc9211bde30329c3258e0e1bf38.zip | |
New thread library
Diffstat (limited to 'src/libthread/test/pthreadloop.c')
| -rw-r--r-- | src/libthread/test/pthreadloop.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/libthread/test/pthreadloop.c b/src/libthread/test/pthreadloop.c new file mode 100644 index 00000000..73b600e7 --- /dev/null +++ b/src/libthread/test/pthreadloop.c @@ -0,0 +1,38 @@ +#include <pthread.h> +#include <utf.h> +#include <fmt.h> + +pthread_key_t key; + +void +pexit(void *v) +{ + int s; + + pthread_setspecific(key, (void*)1); + switch(fork()){ + case -1: + fprint(2, "fork: %r\n"); + case 0: + _exit(0); + default: + wait(&s); + } + pthread_exit(0); +} + +int +main(int argc, char *argv[]) +{ + int i; + pthread_t pid; + + pthread_key_create(&key, 0); + for(i=0;; i++){ + print("%d\n", i); + if(pthread_create(&pid, 0, pexit, 0) < 0){ + fprint(2, "pthread_create: %r\n"); + abort(); + } + } +} |
