请教各位老大

请教各位老大

#!/usr/bin/perl
use warnings;
use strict;
use POSIX 'WNOHANG';
$SIG{CHLD} = \&shouge;

pipe(READER,WRITER);
my $cpid = fork;
if ($cpid == 0) {
    close READER;
    print $$."\n";
    print WRITER "just a test";
}

sub shouge {
    while ((my $kid = waitpid(-1,WNOHANG))>0){
        warn "子进程收割\n";
    }
}

怎么取到这个"just a  test"?


QUOTE:
原帖由 hwxo 于 2008-10-6 12:33 发表
if ($cpid == 0) {
    close READER;
    print $$."\n";
    print WRITER "just a test";
    exit; #子进程退出
}


#父进程
close WRITER;
my @message = <READER>;
close READER;
print "@message\n";

sub shouge {
...
}

父进程读取 READER
多谢楼上的兄弟,子进程不能关闭READER句柄。在父进程里面读。