Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <pthread.h>
- #include <string.h>
- #include <sys/file.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <signal.h>
- #include <unistd.h>
- #include <time.h>
- void *fun_watek1(void * p);
- char* message;
- int main() {
- pthread_t watek1;
- pthread_create(&watek1, NULL, fun_watek1, (void *)&message);
- sleep(2);
- pthread_kill(watek1, SIGHUP);
- pthread_join(watek1, NULL);
- return 0;
- }
- void *fun_watek1(void * p) {
- int koniec = 0;
- void syghup(int a)
- {
- printf("Otrzymalem sygnal. Koniec\n");
- koniec=1;
- }
- signal(SIGHUP, &syghup);
- printf("Watek 1: %lu, PID: %d\n", pthread_self(), getpid());
- for(;;){
- if(koniec==1) break;
- };
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement