Untitled
unknown
plain_text
3 years ago
585 B
6
Indexable
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> #include <sys/wait.h> int main(int argc, char *argv[]) { int fd[2]; if (pipe(fd) == -1) { perror("error"); return 0; } int id = fork(); if (id == 0) { printf("je suis fils\n"); dup2(fd[1], 1); close(fd[0]); close(fd[1]); execlp("ls", "ls", "-l", argv[1], NULL); } wait(NULL); printf("je suis pere\n"); dup2(fd[0], 0); close(fd[0]); close(fd[1]); execlp("grep", "grep", argv[2], NULL); }
Editor is loading...