Thanx for the homework alert! I don't see why you need to dup() your pipes when the shell's pipes are uni-directional. When you do something like this "echo test>one.txt, the string "test" is thrown into a outputed /created one.txt (stdout2file), erasing any previous contents of the file. The less-than sign goes in the opposite direction, piping stuff from a file to the program (file2stdin). The pipe operator sends the stdout from the first program to the stdin of the second. Remember to implement the stderr pipe! For the pipe operator, all you need to do is fork, pipe the stdout to the parent, exec(); fork the parent again, pipe the stdin to the parent and link the pipes in the parent. To visualize this, try "man perlfunc|less". This is exactly the system used in all UNIX shells. For more detailed information, you can look up the whole procedure in W. Richard Stevens' "Advanced Programming in the UNIX Environment". I think this program is mentioned and implemented on his
website. if you need more info, /msg
me. have fun!
Update: Just thought of it- you'll probably get errors if you leave do your buffering poorly. try to buffer only in the parent of the two porcesses.
AgentM Systems nor Nasca Enterprises nor
Bone::Easy nor Macperl is responsible for the
comments made by
AgentM. Remember, you can build any logical system with NOR.