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.

In reply to Re: Dup & redirecting filehandles by AgentM
in thread Dup & redirecting filehandles by Magius_AR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.