use strict; use warnings; use Socket; use IO::Handle; my ($kidfh, $dadfh); socketpair($kidfh, $dadfh, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $!"; $kidfh->autoflush(1); $dadfh->autoflush(1); if (my $pid = fork) { close $dadfh; print $kidfh "Parent Pid $$ sendet dies\n"; chomp(my $line = <$kidfh>); print "Parent Pid $$ liest gerade dies: $line\n"; close $kidfh; waitpid($pid,0); } else { close $kidfh; chomp(my $line = <$dadfh>); print "Child Pid $$ liest gerade dies: $line\n"; print $dadfh "Child Pid $$ sendet dies\n"; close $dadfh; exit; }