if ($pid = fork) { # parent ... } elsif ($pid == 0) { child ... exit; } #### pipe(PIPE_READ,PIPE_WRITE); autoflush PIPE_WRITE 1; #my $pid = fork(); if ($pid = fork) { # parent $SIG{CHLD} = \&chld_handler; &read_pipe; } elsif (defined $pid) { # child &write_pipe ($pid); exit; } else { die "cannot fork: $!"; } sub chld_handler { warn "parent got signal @_\n"; waitpid($pid,0); exit; } sub write_pipe { print "child pid $$ \n"; while(1) { sleep 1; print "Enter message: "; my $usr_msg = ; chomp $usr_msg; last unless $usr_msg; print "child pid = $$ message = $usr_msg\n"; print PIPE_WRITE "$usr_msg\n"; } } sub read_pipe { print "parent here. child pid = $pid\n"; while ( my $msg_read = ) { print "received from pipe $msg_read"; } }