Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<signal.h>
- #include<unistd.h>
- #include<signal.h>
- #include<sys/types.h>
- #include<sys/wait.h>
- #include<stdio.h>
- #include<pwd.h>
- void sign(int sig)
- {
- switch(sig)
- {
- case SIGUSR1:
- printf("Serwer: dostalem od klienta wiadomosc typu 1\n");
- break;
- case SIGUSR2:
- printf("Serwer: dostalem od klienta wiadomosc typu 2\n");
- break;
- }
- }
- int main()
- {
- struct sigaction my_sig;
- my_sig.sa_handler = sign;
- printf("Moj pid: %d\n", getpid());
- while(1)
- {
- sigaction(SIGUSR1, &my_sig, NULL);
- sigaction(SIGUSR2, &my_sig, NULL);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement