Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- #include <sys/wait.h>
- int calculation(int a, int b, int c)
- {
- return ( a || b && c);
- }
- int print_str(int a, int b, int c, int answer)
- {
- char str[64];
- sprintf(str,"%d || %d && %d = %d \n", a, b, c, answer);
- write(1,str,strlen(str));
- return 0;
- }
- int main()
- {
- pid_t a = fork();
- pid_t b = fork();
- pid_t c = fork();
- int answer = calculation(a,b,c);
- print_str(a,b,c,answer);
- wait(NULL); //Ожидание завершения процесса, идентификатор которого равен иднтификатору текущего процесса
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement