#!/usr/bin/perl -w
use Socket;
use IO::Handle;

socketpair(CHILD, PARENT, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
    or die "socketpair: $!";

CHILD->autoflush(1);
PARENT->autoflush(1);
if($pid = fork) {
    close PARENT;
    print CHILD "Parent Pid $$ is sending this.\n";
    chomp($line = <CHILD>);
    print "Parent Pid $$ just read this: '$line'\n";
    close CHILD;
    waitpid($pid,0);
} else {
    die "cannot fork: $!" unless defined $pid;
    close CHILD;
    chomp($line = <PARENT>);
    print PARENT "Child Pid $$ just read this: '$line'\n";
    close PARENT;
    exit;
}


# Local Variables: ***
# mode: Perl ***
# End: ***
