UPDATE:
the code doesn't work, the problem was that <CHILD> reads upon \n and with a prompt, that could be a problem.

too hasty post:
i've been messing around in your code and this seems to work:

use Socket; use IO::Handle; use POSIX ":sys_wait_h"; my $childPid; socketpair(CHILD, PARENT, AF_UNIX, SOCK_STREAM, PF_UNSPEC); CHILD->autoflush(1); PARENT->autoflush(1); die "no child fork" unless defined($childPid=fork()); if ($childPid){ shutdown(PARENT,0); print "about to read\n"; while (<CHILD>){ last if (/Are you ready\? > /); print "got $_"; } print PARENT "yes\n"; print "we're ready\n"; } else { print "waiting for pid..\n"; } open(STDOUT, ">&",PARENT) or die "Can't dup stdout: $!\n"; open(STDIN, "<&",PARENT) or die "Can't dup stdin: $!\n"; exec "./fill.pl" or die "Can't start my program: $!\n"; shutdown(CHILD,1);
and i used this as the fill.pl:
#!/usr/bin/perl print <<END; bla bla bla bla bla bla lb alb blla bla bla bla bla bla END ASK: print "Are you ready? > \n"; $a=<STDIN>; if ($a =~ /yes/) {print "bla bla bla";exit 0;} else {goto ASK;}

hope this helps

--
to ask a question is a moment of shame
to remain ignorant is a lifelong shame

In reply to Re: Communicating with unflushed child process by insaniac
in thread Communicating with unflushed child process by gri6507

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.