Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //~ Написать программу на СИ, обрабатывающую каждое четное возникновение
- //~ сигнала SIGTRAP формированием двух сыновних процессов, связанных каналом.
- //~ ---------------------------------------------------------------
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <fcntl.h>
- #include <signal.h>
- #include <string.h>
- void TrapHandler(int SigN);
- int count=0; //переменная четности получения сигнала
- int main(int argc, char**argv)
- {
- signal(SIGTRAP,TrapHandler);
- for(;;);
- return 0;
- }
- void TrapHandler(int Sign)
- {
- int PD[2];
- signal(SIGTRAP,TrapHandler);
- count++;
- if(count%2==0)
- {
- pipe(PD);
- if (fork()) //предок
- if (fork()) //предок
- { close(PD[0]); close(PD[1]); }
- else //дочерний процесс #1
- for(;;);
- else //дочерний процесс #2
- for(;;);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment