use strict; use Socket; use IO::Handle; my $childPid; socketpair(CHILD, PARENT, AF_UNIX, SOCK_STREAM, PF_UNSPEC); CHILD->autoflush(1); PARENT->autoflush(1); die unless defined($childPid=fork()); if ($childPid){ close PARENT; print "about toread\n"; while (){ print "got $_"; last if (/InputPrompt/); } print CHILD "MyInput\n"; waitpid($childPid) exit; } close CHILD; open(STDOUT, ">&PARENT") or die "Can't dup stdout: $!\n"; open(STDIN, "<&PARENT") or die "Can't dup stdin: $!\n"; exec "myProgram" or die "Can't start my program: $!\n"; #### #include #include int main(int argc, char* argv[]) { char b[32]; printf("Hello there\n"); printf("InputPrompt:\n "); gets(b); printf("Thanks, %s (%s)\n", b, argv[0]); }