#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdio.h>
int main(){
int pipefd[2];
int status = pipe(pipefd);
int child = fork();
printf("%d",child);
if(!child){
wait(NULL);
dup2(pipefd[0],0);
int temp = execl("/bin/sort","sort",NULL);
close(pipefd[0]);
}else{
if(!status){
dup2(pipefd[1],1);
close(pipefd[1]);
int temp = execl("/bin/ls","ls",NULL);
}else{
printf("Pipe error\n");
}
}
return 1;
}
Here in the above code my aim is to read from child process and the parent process read from the pipefd[0] but I don't why it is not getting printed...