- Feb 3, 2005
- 7,326
- 2
- 76
I'm working on creating a basic Unix shell in C. So far, it can read in commands and arguments and execute them (ex: "man ls" brings up the man page for ls like it should). It also supports inputting from or outputting to other files instead of just stdin/stdout. So, I've been using fork(), dup() and dup2(), execvp(), and so on.
I am now trying to implement piping into the shell. I've found a lot of information on how to pipe two or three commands together, but barely anything on 'n' number of commands ('n' being as many commands as I want to enter in the shell).
Currently, my code sets up a linked list that contains all the separate commands I enter into the command line and the number of arguments for each command. Using the shell code I had before, I have it currently set up to loop through each separate command in the linked list and execute them. So, for example, if I type "man ls | man ls | man ls", it will execute that 3 times (one after the other). I only did this to ensure that my linked list was working properly.
Does anyone have any tips on how I might be able to approach this multiple piping problem? I'm going to keep searching around and try to use what I do know to get it working.
I am now trying to implement piping into the shell. I've found a lot of information on how to pipe two or three commands together, but barely anything on 'n' number of commands ('n' being as many commands as I want to enter in the shell).
Currently, my code sets up a linked list that contains all the separate commands I enter into the command line and the number of arguments for each command. Using the shell code I had before, I have it currently set up to loop through each separate command in the linked list and execute them. So, for example, if I type "man ls | man ls | man ls", it will execute that 3 times (one after the other). I only did this to ensure that my linked list was working properly.
Does anyone have any tips on how I might be able to approach this multiple piping problem? I'm going to keep searching around and try to use what I do know to get it working.