SHARE
TWEET

Serwer

RemigiuszP Nov 17th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<signal.h>
  3. #include<unistd.h>
  4. #include<signal.h>
  5. #include<sys/types.h>
  6. #include<sys/wait.h>
  7. #include<stdio.h>
  8. #include<pwd.h>
  9.  
  10.  
  11. void sign(int sig)
  12. {
  13.     switch(sig)
  14.     {
  15.         case SIGUSR1:
  16.             printf("Serwer: dostalem od klienta wiadomosc typu 1\n");
  17.         break;
  18.         case SIGUSR2:
  19.             printf("Serwer: dostalem od klienta wiadomosc typu 2\n");
  20.         break;
  21.     }
  22.    
  23. }
  24.  
  25. int main()
  26. {
  27.     struct sigaction my_sig;
  28.     my_sig.sa_handler = sign;
  29.    
  30.     printf("Moj pid: %d\n", getpid());
  31.    
  32.     while(1)
  33.     {
  34.         sigaction(SIGUSR1, &my_sig, NULL);
  35.         sigaction(SIGUSR2, &my_sig, NULL);
  36.        
  37.     }
  38.    
  39.    
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top