Pipeline implementation in C
I'm a student in uni, currently taking a course in OS.
My current crisis is in implementing a pipeline using C. The implementation below allows TWO commands to be piped: --------------------------------------------------------------------- main(int ac, char *av[]){ int p[2]; pipe(p); if(fork( ) ){ dup2(p[1],1) close(p[0]); close(p[1]); execlp(av[1], av[1], 0); } else { dup2(p[0],0); close(p[0]); close(p[1]); execlp(av[2],av[2],0); } } --------------------------------------------------------- when the command is executed: a.out who wc the effect is the same as executing: who | wc The problem is to modify the above program such that the command: a.out command1 command2 command3 ... commandN has the same effect as: command1 | command2 | command3 | ... | command N using only the five system calls: dup2( ), pipe( ), execlp( ), fork( ), close( ). Can any one help, pls? |
no, we are not here to do your homework for you. if your uni is worth a light then they will have provided you with ample resources to deal with this assignment.
|
All times are GMT -5. The time now is 02:25 AM. |