Toy shell not piping correctly

I’m virtually certain this is what you’re trying to do. Apologies in advance for the sloppy coding. its somewhat late here and I really should be sleeping right now: #include <iostream> #include <string> #include <cstdlib> #include <cstdio> #include <unistd.h> #define READ 0 #define WRITE 1 // ps -A | grep argv[1] | wc -l int … Read more

Pipes, dup2 and exec()

You need to close all the pipe descriptors in both the parent process and the child process (after duplication in the child process). In your code the main issue is that, the wc process does not exit because there are still writers present (since the parent process has not closed the write end). Changes shown … Read more