threadederrno.c revision e739ac0589b4fb43561f801c4faba8c1b89f8680
1 2#include <pthread.h> 3#include <stdio.h> 4#include <errno.h> 5#include <string.h> 6 7 8void* thr2 ( void* v ) 9{ 10 FILE* f = fopen("bogus2", "r"); 11 printf("f = %ld, errno = %d (%s)\n", (long)f, errno, strerror(errno)); 12 return NULL; 13} 14 15void* thr3 ( void* v ) 16{ 17 FILE* f = fopen("bogus3", "r"); 18 printf("f = %ld, errno = %d (%s)\n", (long)f, errno, strerror(errno)); 19 return NULL; 20} 21 22 23int main ( void ) 24{ 25 FILE* f; 26 pthread_t tid2, tid3; 27 pthread_create(&tid2, NULL, &thr2, NULL); 28 pthread_create(&tid3, NULL, &thr3, NULL); 29 f = fopen("bogus", "r"); 30 printf("f = %ld, errno = %d (%s)\n", (long)f, errno, strerror(errno)); 31 pthread_join(tid2, NULL); 32 pthread_join(tid3, NULL); 33 return 0; 34} 35 36