Advertisement
kcku

Untitled

Nov 27th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h> /* Get declaration of strerror() */
  3. #include <pthread.h>
  4. #include "tlpi_hdr.h"
  5. static void *threadFunc(void *arg)
  6. {
  7.     char *str;
  8.     printf("Other thread about to call strerror()\n");
  9.     str = strerror(EPERM);
  10.     printf("Other thread: str (%p) = %s\n", str, str);
  11.     return NULL;
  12. }
  13. int main(int argc, char *argv[])
  14. {
  15.     pthread_t t;
  16.     int s;
  17.     char *str;
  18.     str = strerror(EINVAL);
  19.     printf("Main thread has called strerror()\n");
  20.     s = pthread_create(&t, NULL, threadFunc, NULL);
  21.     if (s != 0)
  22.         errExitEN(s, "pthread_create");
  23.     s = pthread_join(t, NULL);
  24.     if (s != 0)
  25.         errExitEN(s, "pthread_join");
  26.     printf("Main thread: str (%p) = %s\n", str, str);
  27.     exit(EXIT_SUCCESS);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement