Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* pretende-se que o filho termine depois do pai usando pipes */
- // processos e pipes (pipes, fork)
- // Apple Xcode
- // paulogp
- #include <stdio.h>
- #include <unistd.h>
- int main (int argc, const char * argv[])
- {
- int the_pid;
- int the_pfd[2];
- char the_char;
- // postfix delivery to external command
- // the pipe daemon processes requests from the Postfix
- // queue manager to deliver messages to external commands
- pipe(the_pfd); // uma vez mais, sem verificacao de erros
- the_pid = fork();
- if (the_pid == 0)
- {
- read(the_pfd[0], &the_char, 1); // wait for parent
- printf("%d\n", getpid());
- }
- else
- {
- printf("%d\n", getpid());
- write(the_pfd[1], "c", 1);
- }
- printf("\ndone\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement