CS110 Homework
CS110 Homework
- Pipeline:
void pipeline(char *argv1[], char *argv2[], pid_t pids[]);
Pipeline takes two lists of strings (for example, pipeline({"sleep", "10", NULL}, {"sleep", "10", NULL}, pids)) and daisy-chains them so that STDOUT of the first goes to STDIN of the second. Then the third argument is populated with their pids.
To do this, we need to fork. The child should record its STDOUT, then fork again. Now PIPE the second child’s STDIN and the first child’s STDIN. Finally, execvp both processes and return.