This program should emulate the pipe command usage aout ls
/*
This program should emulate the pipe command.
usage: ./a.out ls wc
This should return the equivalent of ls | wc if typed on terminal.
The program requires TWO CHILD processors.
|----------------| |--------------|
Child1 ls -> | pipe | -> Child2 wc -> | pipe | -> ls | wc -> STDOUT
|---------------| |--------------|
Right now when used ./a.out ls wc it only does the second command, wc. but missed ls all toger.
When using ./a.out wc ls it does the same. It is only reading the second command.
Sometimes it gets stucked wainting on a child to finish.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
enum { READ, WRITE };
int main(int argc, char* argv[])
{
int fd[2];
if (pipe(fd) == -1){ /* generate the pipe */
perror(\"Pipe\");
exit(1);
}
switch (fork()){
case -1:
perror(\"Fork\");
exit(2);
case 0: /* in Child1 */
dup2(fd[WRITE], fileno(stdout));
close(fd[READ]);
close(fd[WRITE]);
execvp(argv[1], &argv[1]);
exit(3);
default: /* Lets create another Child*/
switch (fork()){
case -1:
perror(\"Fork\");
exit(2);
case 0: /* in Child2*/
dup2(fd[READ], fileno(stdin));
close(fd[READ]);
close(fd[WRITE]);
execvp(argv[2], &argv[2]);
exit(4);
default: /* in parent */
printf(\"Wainting on a child\ \");
wait(NULL);
printf(\"Wainting on ANOTHER child\ \");
wait(NULL);
printf(\"Finishing up....\ \");
}
}
return 0;
}
Solution
expose class/subclass relationships, use</li></ul>U<br/>14<br/>
eleven. Subclasses and Superclasses<br/>14<br/>
12. characteristic Inheritance in Superclass/Subclass Relationships <br/><ul><li>An entity this is member of a subclass inherits all attributes of the entity as a member of the superclass
13. It additionally inherits all relationships </li></ul>14<br/>
14. Specialization<br/><ul><li>Specialization constructs the lower level entity sets which might be a subset of a better level entity set.
15. Is the manner of defining a set of subclasses of a superclass
16. The set of subclasses is primarily based upon some distinguishing traits of the entities in the superclass

