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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.