added todos from bug reports from cpan
[urisagit/File-Slurp.git] / t / foo2.pl
CommitLineData
635c7876 1#!/usr/local/bin/perl
2 sub pipe_to_fork ($) {
3 my $parent = shift;
4 pipe my $child, $parent or die;
5 my $pid = fork();
6 die "fork() failed: $!" unless defined $pid;
7 if ($pid) {
8 close $child;
9 }
10 else {
11 close $parent;
12 open(STDIN, "<&=" . fileno($child)) or die;
13 }
14 $pid;
15 }
16
17 if (pipe_to_fork('FOO')) {
18 # parent
19 print FOO "pipe_to_fork\n";
20 close FOO;
21 }
22 else {
23 # child
24 while (<STDIN>) { print; }
25 close STDIN;
26 exit(0);
27 }