} 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);
}