Hi I have a quick question which is not strictly a "perl" problem. I am forking and exec'ing in a script. The command that I am exec'ing pipes the output from one command to another command. I then wait on the child in the parent and I want to collect the return status of the first process and not the second. Basically, I have something like
if (fork()){ } else { exec "com1 | com2"; }
And I have a signal handler that reaps the child and does a check for $? to get the status. However as expected, it returns the exit status of "com2". Is there any way to do what I want to do? I've tried looking at some other message boards and I think people get around it by playing around with named pipes and echoing each individual exit status back to the shell. What I want is to have the child process return the status of "com1" back to the parent. Is this possible? I'm sure it is possible but is there an elegant solution to it? Thanks in advance for any reply.

In reply to Returning status to parent from pipe by morrin

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.