SHARE
TWEET

Untitled

a guest Jan 19th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <signal.h>
  4. #include <unistd.h>
  5.  
  6. int main(){
  7.     int i;
  8.     int pid[3];
  9.     int signals[3];
  10.     int signal,process_id;
  11.     FILE* PIDs_file;
  12.     signals[0]=10;//Wstrzymanie SIGUSR1
  13.     signals[1]=12;//Wznowienie SIGUSR2
  14.     signals[2]=2;//Koniec dzialania SIGINT
  15.  
  16.     for(;;){   
  17.         printf("Wybierz signal : \n");
  18.         printf("1. Wstrzymaj prace procesu\n");
  19.         printf("2. Wznow prace procesu\n");
  20.         printf("3. Zakoncz prace procesow\n");
  21.         printf("4. Wyjdz z programu\n");
  22.         scanf("%d",&signal);
  23.         getchar();//usuniecie entera
  24.  
  25.         if(signal == 4)return 0;
  26.  
  27.         printf("Wybierz proces: \n");
  28.         printf("1.Proces P1\n");
  29.         printf("2.Proces P2\n");
  30.         printf("3.Proces P3\n");
  31.         scanf("%d",&process_id);
  32.         getchar();//usuniecie entera
  33.  
  34.         if(PIDs_file = fopen("PID_info.txt","r")){
  35.         for(i=0;i<=2;i++) fscanf(PIDs_file,"%d",&pid[i]);
  36.         fclose(PIDs_file);
  37.         }else printf("Nie znaleziono pliku pids.txt");
  38.  
  39.         kill(pid[process_id-1], signals[signal-1]);
  40.     }
  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