Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <signal.h>
- pid_t p1;
- void wypisuj(int sig){
- while(1){
- printf(".");
- fflush(stdout);
- sleep(1);
- }
- }
- void pauza(int sig){
- for(;;) ;
- }
- void przekaz_p(int sig){
- kill(p1, sig);
- }
- int main(){
- int pid0, pid1;
- if(fork()==0){
- pid0=getpid();
- printf("Proces P0 o PID: %d\n", pid0);
- signal(SIGINT,przekaz_p);
- signal(SIGCONT,przekaz_p);
- p1=fork();
- if(p1==0){
- pid1=getpid();
- printf("Proces P1 o PID: %d\n\n", pid1);
- signal(SIGINT,pauza);
- signal(SIGCONT,wypisuj);
- wypisuj(1);
- }
- printf("\n");
- return 0;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment