Perl: Process Communcation
- by Shiftbit
Can anyone explain how I can successfully get my process communicating. I find the perldoc on IPC confusing.
What I have so far is:
$| = 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");
}
First Question is what does Perldoc
pipe mean by READHANDLE, WRITEHANDLE?
Second Questions is can I implement a solution without relying on CPAN or other modules?