Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <pthread.h>
  5. #include <string.h>
  6. #include <sys/file.h>
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <signal.h>
  10. #include <unistd.h>
  11. #include <time.h>
  12.  
  13.  
  14. void *fun_watek1(void * p);
  15.  
  16. char* message;
  17.  
  18.  
  19. int main() {
  20.  
  21. pthread_t watek1;
  22.  
  23. pthread_create(&watek1, NULL, fun_watek1, (void *)&message);
  24. sleep(2);
  25. pthread_kill(watek1, SIGHUP);
  26.  
  27. pthread_join(watek1, NULL);
  28.  
  29. return 0;
  30. }
  31.  
  32. void *fun_watek1(void * p) {
  33. int koniec = 0;
  34.  
  35. void syghup(int a)
  36. {
  37. printf("Otrzymalem sygnal. Koniec\n");
  38. koniec=1;
  39. }
  40.  
  41. signal(SIGHUP, &syghup);
  42. printf("Watek 1: %lu, PID: %d\n", pthread_self(), getpid());
  43.  
  44. for(;;){
  45. if(koniec==1) break;
  46. };
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement