【发布时间】:2011-02-03 05:25:08
【问题描述】:
谁能解释我如何成功地让我的流程进行通信?我发现 IPC 上的 perldoc 令人困惑。
到目前为止我所拥有的是:
$| = 1;
$SIG{CHLD} = {wait};
my $parentPid = $$;
if ($pid = fork();) ) {
if ($pid == 0) {
pipe($parentPid, $$);
open PARENT, "<$parentPid";
while (<PARENT>) {
print $_;
}
close PARENT;
exit();
} else {
pipe($parentPid, $pid);
open CHILD, ">$pid";
or error("\nError opening: childPid\nRef: $!\n");
open (FH, "<list")
or error("\nError opening: list\nRef: $!\n");
while(<FH>) {
print CHILD, $_;
}
close FH
or error("\nError closing: list\nRef: $!\n");
close CHILD
or error("\nError closing: childPid\nRef: $!\n);
} else {
error("\nError forking\nRef: $!\n");
}
首先:perldoc pipe 中的
READHANDLE、WRITEHANDLE是什么意思?第二:我能否在不依赖 CPAN 或其他模块的情况下实施解决方案?
(来源:wellho.net)
【问题讨论】: