Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <signal.h>
- #include <unistd.h>
- #include <string.h>
- //#include <>
- int fd[2];
- char *str;
- int l,max;
- void hndr (int sig)
- {
- if (sig == SIGUSR1) {
- if (!fork()){ //процесс-сын
- fgets(str, 100, stdin);
- l = strlen(str);
- kill(getppid(),SIGUSR1);
- for (;;);
- }
- }
- if (sig == SIGINT){
- read (fd[1],&l,sizeof (l));
- if (l>max) max = l;
- }
- if (sig == SIGQUIT){
- _exit (0);
- }
- }
- int main (void)
- {
- str = calloc (102, sizeof(char));
- signal(SIGUSR1, hndr);
- if (!fork()){ //процесс-сын
- pipe(fd);
- fgets(str, 1000, stdin);
- l = strlen(str);
- write(fd[1],l,sizeof (l));
- kill(getppid(),SIGUSR1);
- for (;;);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement