I'm currently trying to build something similar to the |
in linux and it should be able to take n amount of arguments as long as they are piped together. I execute these arguments (like ls
, sort
, etc) using execvp()
by passing it the argument and then the array that holds the argument and its options.
HOWEVER, the proplem lies in that execvp()
does not return anything.. so when i fork()
and go into the child process, it does what it needs to do, execvp()
then goes into the parent process. Now i can recursively fork again and keep on going to get as many child processes as needed and call n amounts of execvp()
but I would like to know if there is ITERATIVE way of doing the same thing.
Hope I was clear enough, it's very late, so sorry for the ambiguity.