X-Git-Url: https://git.piment-noir.org/?p=TD_IML.git;a=blobdiff_plain;f=TD2%2Fexercise3%2Fexercise.c;h=9459ab1e87fefdbbcd5c06427b689ea0cda4e7da;hp=c4e9e4102b0445357a0edacbc31da488abedac5a;hb=9cb0c82389b58f164f115c9fb407e7aacbd77fc6;hpb=000bb88ff53b62a983a73e75b6e19dea79d63981 diff --git a/TD2/exercise3/exercise.c b/TD2/exercise3/exercise.c index c4e9e41..9459ab1 100644 --- a/TD2/exercise3/exercise.c +++ b/TD2/exercise3/exercise.c @@ -23,13 +23,13 @@ int main() { } else if (cpid == 0) { close(pipefd[0]); dup2(pipefd[1], STDOUT_FILENO); - printf("[%d] Hey Jude\n", getpid()); - //execl("/bin/ls", "ls", (char*)NULL); + execl("/bin/ls", "ls", (char*)NULL); close(pipefd[1]); exit(EXIT_SUCCESS); } else { close(pipefd[1]); printf("[%d] REDIRECTION: \n", getpid()); + //determine the pipe size to avoid this kind of code while (read(pipefd[0], &tmpbuf, 1) > 0) { write(STDOUT_FILENO, &tmpbuf, 1); }