I am attempting to learn IPC::Run so that I may implement some privilege separation between daemons for generic operations and specific things that require root.

My child is not returning anything to the parent, apparently because it's not reading from the parent via "while (<STDIN>) {}". How would I get the child to read what the parent sends? My example is below.

The "cat1" is from perldoc IPC::Run, and runs as expected when using cat as the child (I get back on stdout what I used for input). When I use my "wr2" script as the child I get nothing on the parent's stdout. When I use "wr2" separately on the command line I get what I expect:

$ echo 123123 | wr2 123123

I've googled at great length, but all the examples are about being the parent, not being the child.

This is cat1:

#!/usr/bin/perl use warnings; use strict; use IPC::Run qw(start pump finish timeout); #my @cat = qw(/bin/cat); my @cat = qw(/home/cwood/bin/wr2); my ($in, $out, $err); my $h = start \@cat, \$in, \$out, \$err, timeout(10); $in .= "some input\n"; pump $h until $out =~ /input\n/g; $in .= "some more input\n"; pump $h until $out =~ /\G.*more input\n/; $in .= "some final input\n"; finish $h or die "cat returned $?"; warn $err if $err; print $out; ## All of cat's output

This is wr2:

#!/usr/bin/perl use warnings; use strict; while (<STDIN>) { print; }

In reply to How to be a child of IPC::Run? by cwood

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.