test01.c 525 B

123456789101112131415161718192021222324252627282930
  1. #include "unpthread.h"
  2. void *
  3. myfunc(void *ptr)
  4. {
  5. pause();
  6. }
  7. int
  8. main(int argc, char **argv)
  9. {
  10. pthread_t tid;
  11. int n;
  12. /* Let's see what the return value is and what errno is after a error. */
  13. for ( ; ; ) {
  14. errno = 0;
  15. if ( (n = pthread_create(&tid, NULL, myfunc, NULL)) != 0) {
  16. printf("pthread_create returned %d, errno = %d\n", n, errno);
  17. errno = 0;
  18. n = pthread_join(777777, NULL);
  19. printf("pthread_join returned %d, errno = %d\n", n, errno);
  20. exit(0);
  21. }
  22. printf("created tid %d\n", tid);
  23. }
  24. }