For a program I wrote I learned how to redirect stdout from one program to stdin of another program by using dup() etc. Now I am writing my own shell and it's going pretty well (although I need to change it to use ncurses which I haven't really mastered yet but...), but now I want to add the possibility to use pipes.
But the problem is while I've learned how to redirect stdoud and stdin I haven't figured out how to restore stdin and stdout again. Could anyone help me?
What I mean is that if I for example execute from my program (exec*) "ls -l" and pipe it to "grep test". How do I later restore stdin and stdout to go back to putting out output in the terminal and get the input from the keyboard?